From 43d2b1db0e5d0352fcf94eab79b9e0fc5339980b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Oct 2018 17:40:14 +0100 Subject: [PATCH 001/140] Simplify and fix layout of the display sample Get rid of an unnecessary wxPanel and just create wxBookCtrl containing pages showing information about the displays directly as a child of wxFrame. --- samples/display/display.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/samples/display/display.cpp b/samples/display/display.cpp index 7996eac945..ed5420d147 100644 --- a/samples/display/display.cpp +++ b/samples/display/display.cpp @@ -232,9 +232,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, #endif // wxUSE_STATUSBAR // create child controls - wxPanel *panel = new wxPanel(this, wxID_ANY); - - m_book = new wxBookCtrl(panel, wxID_ANY); + m_book = new wxBookCtrl(this, wxID_ANY); const size_t countDpy = wxDisplay::GetCount(); for ( size_t nDpy = 0; nDpy < countDpy; nDpy++ ) { @@ -291,6 +289,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, sizer->Add(new wxStaticText(page, wxID_ANY, display.IsPrimary() ? "yes" : "no")); + // add it to another sizer to have borders around it and button below wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(sizer, 1, wxALL | wxEXPAND, 10); @@ -313,22 +312,19 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, sizer->Add(new wxStaticText(page, Display_CurrentMode, VideoModeToText(display.GetCurrentMode()))); - // add it to another sizer to have borders around it and button below sizerTop->Add(new wxButton(page, Display_ResetMode, "&Reset mode"), 0, wxALL | wxCENTRE, 5); #endif // wxUSE_DISPLAY page->SetSizer(sizerTop); + page->Layout(); m_book->AddPage(page, wxString::Format("Display %lu", (unsigned long)nDpy)); } - wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(m_book, 1, wxEXPAND); - panel->SetSizer(sizer); - sizer->SetSizeHints(this); + SetClientSize(m_book->GetBestSize()); } #if wxUSE_DISPLAY From f09b9dbfa26641fa2b3cfe281e9b13f161b107f9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Oct 2018 17:41:37 +0100 Subject: [PATCH 002/140] Add wxDisplayImpl::GetScaleFactor() and implement it for wxGTK We need to account for the scale factor under GTK+ (and, presumably, under macOS) to compute the correct PPI value as it must use the number of physical and not logical pixels. --- include/wx/private/display.h | 7 +++++-- src/common/dpycmn.cpp | 6 ++++-- src/gtk/display.cpp | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/include/wx/private/display.h b/include/wx/private/display.h index 1cd7bae8d0..053885d05a 100644 --- a/include/wx/private/display.h +++ b/include/wx/private/display.h @@ -81,8 +81,11 @@ public: // return the depth or 0 if unknown virtual int GetDepth() const = 0; - // return the resolution of the display, uses GetSizeMM() by default but - // can be also overridden directly + // return the scale factor used to convert logical pixels to physical ones + virtual double GetScaleFactor() const { return 1.0; } + + // return the resolution of the display, uses GetSize(), GetScaleFactor() + // and GetSizeMM() by default but can be also overridden directly virtual wxSize GetPPI() const; // return the physical size of the display or (0, 0) if unknown: this is diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index d0073ee32c..b72f72c8f6 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -195,9 +195,7 @@ bool wxDisplay::ChangeMode(const wxVideoMode& mode) wxSize wxDisplayImpl::GetPPI() const { - const wxSize pixels = GetGeometry().GetSize(); const wxSize mm = GetSizeMM(); - if ( !mm.x || !mm.y ) { // Physical size is unknown, return a special value indicating that we @@ -205,6 +203,10 @@ wxSize wxDisplayImpl::GetPPI() const return wxSize(0, 0); } + // We need physical pixels here, not logical ones returned by + // GetGeometry(), to compute the real DPI. + const wxSize pixels = GetGeometry().GetSize()*GetScaleFactor(); + return wxSize(wxRound((pixels.x * inches2mm) / mm.x), wxRound((pixels.y * inches2mm) / mm.y)); } diff --git a/src/gtk/display.cpp b/src/gtk/display.cpp index 07e1fc45f3..b5eedeab71 100644 --- a/src/gtk/display.cpp +++ b/src/gtk/display.cpp @@ -46,6 +46,7 @@ public: virtual wxRect GetGeometry() const wxOVERRIDE; virtual wxRect GetClientArea() const wxOVERRIDE; virtual int GetDepth() const wxOVERRIDE; + virtual double GetScaleFactor() const wxOVERRIDE; virtual wxSize GetSizeMM() const wxOVERRIDE; #if wxUSE_DISPLAY @@ -121,6 +122,11 @@ int wxDisplayImplGTK::GetDepth() const return 24; } +double wxDisplayImplGTK::GetScaleFactor() const +{ + return gdk_monitor_get_scale_factor(m_monitor); +} + wxSize wxDisplayImplGTK::GetSizeMM() const { return wxSize @@ -222,6 +228,9 @@ public: virtual wxRect GetGeometry() const wxOVERRIDE; virtual wxRect GetClientArea() const wxOVERRIDE; virtual int GetDepth() const wxOVERRIDE; +#if GTK_CHECK_VERSION(3,10,0) + virtual double GetScaleFactor() const wxOVERRIDE; +#endif // GTK+ 3.10 virtual wxSize GetSizeMM() const wxOVERRIDE; #if wxUSE_DISPLAY @@ -293,6 +302,16 @@ int wxDisplayImplGTK::GetDepth() const return gdk_visual_get_depth(gdk_window_get_visual(wxGetTopLevelGDK())); } +#if GTK_CHECK_VERSION(3,10,0) +double wxDisplayImplGTK::GetScaleFactor() const +{ + if ( gtk_check_version(3,10,0) == NULL ) + return gdk_screen_get_monitor_scale_factor(m_screen, m_index); + + return 1.0; +} +#endif // GTK+ 3.10 + wxSize wxDisplayImplGTK::GetSizeMM() const { // At least in some configurations, gdk_screen_xxx_mm() functions return From 1938adb5dc3d0593210c774cfaae09ca5a3b3fd3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Oct 2018 17:50:56 +0100 Subject: [PATCH 003/140] Don't use gdk_screen_xxx_mm() with multiple displays These functions combine the sizes of all displays and so only return the correct size when there is only a single display. This fixes wildly wrong PPI values returned when more than one display is used. --- src/gtk/display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gtk/display.cpp b/src/gtk/display.cpp index b5eedeab71..281901cc70 100644 --- a/src/gtk/display.cpp +++ b/src/gtk/display.cpp @@ -317,7 +317,7 @@ wxSize wxDisplayImplGTK::GetSizeMM() const // At least in some configurations, gdk_screen_xxx_mm() functions return // valid values when gdk_screen_get_monitor_xxx_mm() only return -1, so // handle this case specially. - if ( IsPrimary() ) + if ( gdk_screen_get_n_monitors(m_screen) == 1 ) { return wxSize(gdk_screen_width_mm(), gdk_screen_height_mm()); } From 68a7cbd08de59623640c6f0cfd9e3881d2230c35 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Oct 2018 18:01:23 +0100 Subject: [PATCH 004/140] Use gdk_screen_xxx_mm() as fallback only Return the "real" PPI value from wxDisplay::GetPPI() in wxGTK and not the value defined at X11 level which is what these functions seem to use. --- src/gtk/display.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gtk/display.cpp b/src/gtk/display.cpp index 281901cc70..7c79456758 100644 --- a/src/gtk/display.cpp +++ b/src/gtk/display.cpp @@ -314,14 +314,6 @@ double wxDisplayImplGTK::GetScaleFactor() const wxSize wxDisplayImplGTK::GetSizeMM() const { - // At least in some configurations, gdk_screen_xxx_mm() functions return - // valid values when gdk_screen_get_monitor_xxx_mm() only return -1, so - // handle this case specially. - if ( gdk_screen_get_n_monitors(m_screen) == 1 ) - { - return wxSize(gdk_screen_width_mm(), gdk_screen_height_mm()); - } - wxSize sizeMM; #if GTK_CHECK_VERSION(2,14,0) if ( wx_is_at_least_gtk2(14) ) @@ -337,6 +329,19 @@ wxSize wxDisplayImplGTK::GetSizeMM() const sizeMM.y = rc; } #endif // GTK+ 2.14 + + // When we have only a single display, we can use global GTK+ functions. + // Note that at least in some configurations, these functions return valid + // values when gdk_screen_get_monitor_xxx_mm() only return -1, so it's + // always worth fallng back on them, but we can't do it when using + // multiple displays because they combine the sizes of all displays in this + // case, which would result in a completely wrong value for GetPPI(). + if ( !(sizeMM.x && sizeMM.y) && gdk_screen_get_n_monitors(m_screen) == 1 ) + { + sizeMM.x = gdk_screen_width_mm(); + sizeMM.y = gdk_screen_height_mm(); + } + return sizeMM; } From 9f8684c789a5dd956254b1abbac15a42ee178983 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Oct 2018 18:31:42 +0100 Subject: [PATCH 005/140] Factor out wxDisplayImpl::ComputePPI() helper No real changes, this is a pure refactoring. --- include/wx/private/display.h | 5 +++++ src/common/dpycmn.cpp | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/wx/private/display.h b/include/wx/private/display.h index 053885d05a..9a97a75f9c 100644 --- a/include/wx/private/display.h +++ b/include/wx/private/display.h @@ -118,6 +118,11 @@ protected: // create the object providing access to the display with the given index wxDisplayImpl(unsigned n) : m_index(n) { } + // Compute PPI from the sizes in pixels and mm. + // + // Return (0, 0) if physical size (in mm) is not known, i.e. 0. + static wxSize ComputePPI(int pxX, int pxY, int mmX, int mmY); + // the index of this display (0 is always the primary one) const unsigned m_index; diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index b72f72c8f6..53311f86ef 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -193,22 +193,29 @@ bool wxDisplay::ChangeMode(const wxVideoMode& mode) // wxDisplayImpl implementation // ============================================================================ -wxSize wxDisplayImpl::GetPPI() const +/* static */ +wxSize wxDisplayImpl::ComputePPI(int pxX, int pxY, int mmX, int mmY) { - const wxSize mm = GetSizeMM(); - if ( !mm.x || !mm.y ) + if ( !mmX || !mmY ) { // Physical size is unknown, return a special value indicating that we // can't compute the resolution -- what else can we do? return wxSize(0, 0); } + return wxSize(wxRound((pxX * inches2mm) / mmX), + wxRound((pxY * inches2mm) / mmY)); +} + +wxSize wxDisplayImpl::GetPPI() const +{ + const wxSize mm = GetSizeMM(); + // We need physical pixels here, not logical ones returned by // GetGeometry(), to compute the real DPI. const wxSize pixels = GetGeometry().GetSize()*GetScaleFactor(); - return wxSize(wxRound((pixels.x * inches2mm) / mm.x), - wxRound((pixels.y * inches2mm) / mm.y)); + return ComputePPI(pixels.x, pixels.y, mm.x, mm.y); } // ============================================================================ From e13df3140f0f9029ffec15c7b0b1e671cf2072b8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Oct 2018 18:31:59 +0100 Subject: [PATCH 006/140] Fall back to display-independent PPI in wxGTK If we can't determine the display-specific PPI value, use the global one which seems to be always available (and always equal to 96*96 in my testing -- but this is what previous versions of wxWidgets returned, so it's still better than nothing). --- src/gtk/display.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gtk/display.cpp b/src/gtk/display.cpp index 7c79456758..7ab2c8d36b 100644 --- a/src/gtk/display.cpp +++ b/src/gtk/display.cpp @@ -231,6 +231,7 @@ public: #if GTK_CHECK_VERSION(3,10,0) virtual double GetScaleFactor() const wxOVERRIDE; #endif // GTK+ 3.10 + virtual wxSize GetPPI() const wxOVERRIDE; virtual wxSize GetSizeMM() const wxOVERRIDE; #if wxUSE_DISPLAY @@ -312,6 +313,24 @@ double wxDisplayImplGTK::GetScaleFactor() const } #endif // GTK+ 3.10 +wxSize wxDisplayImplGTK::GetPPI() const +{ + // Try the base class version which uses our GetSizeMM() and returns + // per-display PPI value if it works. + wxSize ppi = wxDisplayImpl::GetPPI(); + + if ( !ppi.x || !ppi.y ) + { + // But if it didn't work, fall back to the global DPI value common to + // all displays -- this is still better than nothing and more + // compatible with the previous wxWidgets versions. + ppi = ComputePPI(gdk_screen_width(), gdk_screen_height(), + gdk_screen_width_mm(), gdk_screen_height_mm()); + } + + return ppi; +} + wxSize wxDisplayImplGTK::GetSizeMM() const { wxSize sizeMM; From f57cb6c1d99e53d140626785938e594bd2829a2f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 Nov 2018 00:02:47 +0100 Subject: [PATCH 007/140] Add wxDisplay(wxWindow*) ctor with fall back on primary display This is more convenient than calling GetFromWindow() and then checking its return value. --- include/wx/display.h | 4 ++++ interface/wx/display.h | 17 +++++++++++++++++ src/common/dpycmn.cpp | 9 +++++++++ 3 files changed, 30 insertions(+) diff --git a/include/wx/display.h b/include/wx/display.h index af299a74e0..1c3a67298a 100644 --- a/include/wx/display.h +++ b/include/wx/display.h @@ -49,6 +49,10 @@ public: // primary display and the only one which is always supported wxDisplay(unsigned n = 0); + // create display object corresponding to the display of the given window + // or the default one if the window display couldn't be found + explicit wxDisplay(const wxWindow* window); + // dtor is not virtual as this is a concrete class not meant to be derived // from diff --git a/interface/wx/display.h b/interface/wx/display.h index 1a3ca71450..3c4e28f4bb 100644 --- a/interface/wx/display.h +++ b/interface/wx/display.h @@ -26,6 +26,23 @@ public: */ wxDisplay(unsigned int index = 0); + /** + Constructor creating the display object associated with the given + window. + + This is the most convenient way of finding the display on which the + given window is shown while falling back to the default display if it + is not shown at all or positioned outside of any display. + + @param window + A valid, i.e. non-null, window. + + @see GetFromWindow() + + @since 3.1.2 + */ + explicit wxDisplay(const wxWindow* window); + /** Destructor. */ diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index 53311f86ef..6171335b1a 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -85,6 +85,13 @@ wxDisplay::wxDisplay(unsigned n) m_impl = Factory().GetDisplay(n); } +wxDisplay::wxDisplay(const wxWindow* window) +{ + const int n = GetFromWindow(window); + + m_impl = Factory().GetDisplay(n != wxNOT_FOUND ? n : 0); +} + // ---------------------------------------------------------------------------- // static functions forwarded to wxDisplayFactory // ---------------------------------------------------------------------------- @@ -233,6 +240,8 @@ wxDisplayFactory::~wxDisplayFactory() int wxDisplayFactory::GetFromWindow(const wxWindow *window) { + wxCHECK_MSG( window, wxNOT_FOUND, "window can't be NULL" ); + // consider that the window belongs to the display containing its centre const wxRect r(window->GetScreenRect()); return GetFromPoint(wxPoint(r.x + r.width/2, r.y + r.height/2)); From 4ad9cde3805f16958bdb6e072ae072e999ce798d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 Nov 2018 00:06:34 +0100 Subject: [PATCH 008/140] Use the new wxDisplay(wxWindow*) ctor to simplify the code Make the code simpler and, in a couple of places where the fall back to the primary display in case wxDisplay::GetFromWindow() returned -1 was missing, also more correct. --- src/common/dlgcmn.cpp | 2 +- src/common/sizer.cpp | 12 +++--------- src/common/toplvcmn.cpp | 3 +-- src/generic/richtooltipg.cpp | 6 +----- src/msw/msgdlg.cpp | 5 +---- src/msw/toplevel.cpp | 9 ++------- src/stc/PlatWX.cpp | 3 +-- 7 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 55e37cc2e6..a7a6803bb3 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -871,7 +871,7 @@ int wxStandardDialogLayoutAdapter::DoMustScroll(wxDialog* dialog, wxSize& window wxSize minWindowSize = dialog->GetSizer()->GetMinSize(); windowSize = dialog->GetSize(); windowSize = wxSize(wxMax(windowSize.x, minWindowSize.x), wxMax(windowSize.y, minWindowSize.y)); - displaySize = wxDisplay(wxDisplay::GetFromWindow(dialog)).GetClientArea().GetSize(); + displaySize = wxDisplay(dialog).GetClientArea().GetSize(); int flags = 0; diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index ba50b6c9c0..8f2dc9f887 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -930,15 +930,9 @@ wxSize wxSizer::ComputeFittingClientSize(wxWindow *window) return tlw->GetClientSize(); } - // limit the window to the size of the display it is on - int disp = wxDisplay::GetFromWindow(window); - if ( disp == wxNOT_FOUND ) - { - // or, if we don't know which one it is, of the main one - disp = 0; - } - - sizeMax = wxDisplay(disp).GetClientArea().GetSize(); + // limit the window to the size of the display it is on (or the main + // one if the window display can't be determined) + sizeMax = wxDisplay(window).GetClientArea().GetSize(); // If determining the display size failed, skip the max size checks as // we really don't want to create windows of (0, 0) size. diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index a5660a3b23..7619328a18 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -249,8 +249,7 @@ void wxTopLevelWindowBase::DoCentre(int dir) // we need the display rect anyhow so store it first: notice that we should // be centered on the same display as our parent window, the display of // this window itself is not really defined yet - int nDisplay = wxDisplay::GetFromWindow(GetParent() ? GetParent() : this); - wxDisplay dpy(nDisplay == wxNOT_FOUND ? 0 : nDisplay); + wxDisplay dpy(GetParent() ? GetParent() : this); const wxRect rectDisplay(dpy.GetClientArea()); // what should we centre this window on? diff --git a/src/generic/richtooltipg.cpp b/src/generic/richtooltipg.cpp index 574f36b672..b774341d33 100644 --- a/src/generic/richtooltipg.cpp +++ b/src/generic/richtooltipg.cpp @@ -318,11 +318,7 @@ private: // Use GetFromWindow() and not GetFromPoint() here to try to get the // correct display even if the tip point itself is not visible. - int dpy = wxDisplay::GetFromWindow(GetParent()); - if ( dpy == wxNOT_FOUND ) - dpy = 0; // What else can we do? - - const wxRect rectDpy = wxDisplay(dpy).GetClientArea(); + const wxRect rectDpy = wxDisplay(GetParent()).GetClientArea(); #ifdef __WXMAC__ return pos.y > rectDpy.height/2 ? wxTipKind_Bottom : wxTipKind_Top; diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 017991a4b4..61a0a878a8 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -162,10 +162,7 @@ wxMessageDialog::HookFunction(int code, WXWPARAM wParam, WXLPARAM lParam) void wxMessageDialog::ReplaceStaticWithEdit() { // check if the message box fits the display - int nDisplay = wxDisplay::GetFromWindow(this); - if ( nDisplay == wxNOT_FOUND ) - nDisplay = 0; - const wxRect rectDisplay = wxDisplay(nDisplay).GetClientArea(); + const wxRect rectDisplay = wxDisplay(this).GetClientArea(); if ( rectDisplay.Contains(GetRect()) ) { diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index df9e001c93..b883d9d8f9 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -756,8 +756,7 @@ void wxTopLevelWindowMSW::DoGetPosition(int *x, int *y) const { // we must use the correct display for the translation as the // task bar might be shown on one display but not the other one - int n = wxDisplay::GetFromWindow(this); - wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); + wxDisplay dpy(this); const wxPoint ptOfs = dpy.GetClientArea().GetPosition() - dpy.GetGeometry().GetPosition(); @@ -916,11 +915,7 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) // resize to the size of the display containing us, falling back to the // primary one - int dpy = wxDisplay::GetFromWindow(this); - if ( dpy == wxNOT_FOUND ) - dpy = 0; - - const wxRect rect = wxDisplay(dpy).GetGeometry(); + const wxRect rect = wxDisplay(this).GetGeometry(); SetSize(rect); diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 4fd42772bb..ffb3db94bc 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -1861,8 +1861,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { position.x = wxRound(position.x + rc.left); position.y = wxRound(position.y + rc.top); - const int currentDisplay = wxDisplay::GetFromWindow(relativeWin); - const wxRect displayRect = wxDisplay(currentDisplay).GetClientArea(); + const wxRect displayRect = wxDisplay(relativeWin).GetClientArea(); if (position.x < displayRect.GetLeft()) position.x = displayRect.GetLeft(); From 81c67c368647f6efbcd55d2d77c095d738cc7c1c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 Nov 2018 00:07:24 +0100 Subject: [PATCH 009/140] Make wxDC::GetPPI() monitor-dependent in wxGTK3 Return the PPI for the display on which the associated window is shown and not the main display PPI. --- src/gtk/dc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index 3e7868173c..a41910ac32 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -15,6 +15,7 @@ #include "wx/dcclient.h" #include "wx/dcmemory.h" #include "wx/dcscreen.h" +#include "wx/display.h" #include "wx/gdicmn.h" #include "wx/icon.h" #include "wx/gtk/dc.h" @@ -238,7 +239,7 @@ wxSize wxGTKCairoDCImpl::GetPPI() const { if ( m_window ) { - return wxGetDisplayPPI(); + return wxDisplay(m_window).GetPPI(); } // For a non-window-based DC the concept of PPI doesn't make much sense From fe865a174382a42a01ecaec215797b0992d11aa7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 14:34:49 +0100 Subject: [PATCH 010/140] Rewrite wxDataViewCtrl unit test without using CppUnit macros Use CATCH API directly, this simplifies the code and makes adding new tests simpler. No real changes yet. --- tests/controls/dataviewctrltest.cpp | 124 +++++++++++++--------------- 1 file changed, 57 insertions(+), 67 deletions(-) diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index 45c10cf253..d8b20740ed 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -27,30 +27,13 @@ // test class // ---------------------------------------------------------------------------- -class DataViewCtrlTestCase : public CppUnit::TestCase +class DataViewCtrlTestCase { public: - DataViewCtrlTestCase() { } - - virtual void setUp() wxOVERRIDE; - virtual void tearDown() wxOVERRIDE; - -private: - CPPUNIT_TEST_SUITE( DataViewCtrlTestCase ); - CPPUNIT_TEST( DeleteSelected ); - CPPUNIT_TEST( DeleteNotSelected ); - CPPUNIT_TEST( GetSelectionForMulti ); - CPPUNIT_TEST( GetSelectionForSingle ); - CPPUNIT_TEST_SUITE_END(); - - // Create wxDataViewTreeCtrl with the given style. - void Create(long style); - - void DeleteSelected(); - void DeleteNotSelected(); - void GetSelectionForMulti(); - void GetSelectionForSingle(); + explicit DataViewCtrlTestCase(long style); + ~DataViewCtrlTestCase(); +protected: void TestSelectionFor0and1(); // the dataview control itself @@ -65,17 +48,29 @@ private: wxDECLARE_NO_COPY_CLASS(DataViewCtrlTestCase); }; -// register in the unnamed registry so that these tests are run by default -CPPUNIT_TEST_SUITE_REGISTRATION( DataViewCtrlTestCase ); +class SingleSelectDataViewCtrlTestCase : public DataViewCtrlTestCase +{ +public: + SingleSelectDataViewCtrlTestCase() + : DataViewCtrlTestCase(wxDV_SINGLE) + { + } +}; -// also include in its own registry so that these tests can be run alone -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataViewCtrlTestCase, "DataViewCtrlTestCase" ); +class MultiSelectDataViewCtrlTestCase : public DataViewCtrlTestCase +{ +public: + MultiSelectDataViewCtrlTestCase() + : DataViewCtrlTestCase(wxDV_MULTIPLE) + { + } +}; // ---------------------------------------------------------------------------- // test initialization // ---------------------------------------------------------------------------- -void DataViewCtrlTestCase::Create(long style) +DataViewCtrlTestCase::DataViewCtrlTestCase(long style) { m_dvc = new wxDataViewTreeCtrl(wxTheApp->GetTopWindow(), wxID_ANY, @@ -94,27 +89,18 @@ void DataViewCtrlTestCase::Create(long style) m_dvc->Update(); } -void DataViewCtrlTestCase::setUp() -{ - Create(wxDV_MULTIPLE); -} - -void DataViewCtrlTestCase::tearDown() +DataViewCtrlTestCase::~DataViewCtrlTestCase() { delete m_dvc; - m_dvc = NULL; - - m_root = - m_child1 = - m_child2 = - m_grandchild = wxDataViewItem(); } // ---------------------------------------------------------------------------- // the tests themselves // ---------------------------------------------------------------------------- -void DataViewCtrlTestCase::DeleteSelected() +TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase, + "wxDVC::DeleteSelected", + "[wxDataViewCtrl][delete]") { wxDataViewItemArray sel; sel.push_back(m_child1); @@ -128,14 +114,18 @@ void DataViewCtrlTestCase::DeleteSelected() m_dvc->GetSelections(sel); // m_child1 and its children should be removed from the selection now - CPPUNIT_ASSERT_EQUAL( 1, sel.size() ); - CPPUNIT_ASSERT( sel[0] == m_child2 ); + REQUIRE( sel.size() == 1 ); + CHECK( sel[0] == m_child2 ); } -void DataViewCtrlTestCase::DeleteNotSelected() +TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase, + "wxDVC::DeleteNotSelected", + "[wxDataViewCtrl][delete]") { // TODO not working on OS X as expected -#ifndef __WXOSX__ +#ifdef __WXOSX__ + WARN("Disabled under MacOS because this test currently fails"); +#else wxDataViewItemArray sel; sel.push_back(m_child1); sel.push_back(m_grandchild); @@ -147,9 +137,9 @@ void DataViewCtrlTestCase::DeleteNotSelected() m_dvc->GetSelections(sel); // m_child1 and its children should be unaffected - CPPUNIT_ASSERT_EQUAL( 2, sel.size() ); - CPPUNIT_ASSERT( sel[0] == m_child1 ); - CPPUNIT_ASSERT( sel[1] == m_grandchild ); + REQUIRE( sel.size() == 2 ); + CHECK( sel[0] == m_child1 ); + CHECK( sel[1] == m_grandchild ); #endif } @@ -158,43 +148,43 @@ void DataViewCtrlTestCase::TestSelectionFor0and1() wxDataViewItemArray selections; // Initially there is no selection. - CPPUNIT_ASSERT_EQUAL( 0, m_dvc->GetSelectedItemsCount() ); - CPPUNIT_ASSERT( !m_dvc->HasSelection() ); - CPPUNIT_ASSERT( !m_dvc->GetSelection().IsOk() ); + CHECK( m_dvc->GetSelectedItemsCount() == 0 ); + CHECK( !m_dvc->HasSelection() ); + CHECK( !m_dvc->GetSelection().IsOk() ); - CPPUNIT_ASSERT( !m_dvc->GetSelections(selections) ); - CPPUNIT_ASSERT( selections.empty() ); + CHECK( !m_dvc->GetSelections(selections) ); + CHECK( selections.empty() ); // Select one item. m_dvc->Select(m_child1); - CPPUNIT_ASSERT_EQUAL( 1, m_dvc->GetSelectedItemsCount() ); - CPPUNIT_ASSERT( m_dvc->HasSelection() ); - CPPUNIT_ASSERT( m_dvc->GetSelection().IsOk() ); - CPPUNIT_ASSERT_EQUAL( 1, m_dvc->GetSelections(selections) ); - CPPUNIT_ASSERT( selections[0] == m_child1 ); + CHECK( m_dvc->GetSelectedItemsCount() == 1 ); + CHECK( m_dvc->HasSelection() ); + CHECK( m_dvc->GetSelection().IsOk() ); + REQUIRE( m_dvc->GetSelections(selections) == 1 ); + CHECK( selections[0] == m_child1 ); } -void DataViewCtrlTestCase::GetSelectionForMulti() +TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase, + "wxDVC::GetSelectionForMulti", + "[wxDataViewCtrl][select]") { wxDataViewItemArray selections; TestSelectionFor0and1(); - // Also test with more than one selected item. m_dvc->Select(m_child2); - CPPUNIT_ASSERT_EQUAL( 2, m_dvc->GetSelectedItemsCount() ); - CPPUNIT_ASSERT( m_dvc->HasSelection() ); - CPPUNIT_ASSERT( !m_dvc->GetSelection().IsOk() ); - CPPUNIT_ASSERT_EQUAL( 2, m_dvc->GetSelections(selections) ); - CPPUNIT_ASSERT( selections[1] == m_child2 ); + CHECK( m_dvc->GetSelectedItemsCount() == 2 ); + CHECK( m_dvc->HasSelection() ); + CHECK( !m_dvc->GetSelection().IsOk() ); + REQUIRE( m_dvc->GetSelections(selections) == 2 ); + CHECK( selections[1] == m_child2 ); } -void DataViewCtrlTestCase::GetSelectionForSingle() +TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, + "wxDVC::SingleSelection", + "[wxDataViewCtrl][selection]") { - delete m_dvc; - Create(0); - TestSelectionFor0and1(); } From 05ae63e40a0bae7fa34e3be8edf0d3ed5092584a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 14:54:53 +0100 Subject: [PATCH 011/140] Use standard naming convention for RowToTreeNodeJob members Prefix them with "m_" to indicate that they're member variables. No real changes. --- src/generic/datavgen.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 2e1d1887e1..1ad0120fb3 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3468,31 +3468,28 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const class RowToTreeNodeJob: public DoJob { public: - RowToTreeNodeJob( unsigned int row_ , int current_, wxDataViewTreeNode * node ) + RowToTreeNodeJob(unsigned int row, int current, wxDataViewTreeNode *parent) + : m_row(row), m_current(current), m_parent(parent), m_ret(NULL) { - this->row = row_; - this->current = current_; - ret = NULL; - parent = node; } virtual int operator() ( wxDataViewTreeNode * node ) wxOVERRIDE { - current ++; - if( current == static_cast(row)) + m_current ++; + if( m_current == static_cast(m_row)) { - ret = node; + m_ret = node; return DoJob::DONE; } - if( node->GetSubTreeCount() + current < static_cast(row) ) + if( node->GetSubTreeCount() + m_current < static_cast(m_row) ) { - current += node->GetSubTreeCount(); + m_current += node->GetSubTreeCount(); return DoJob::SKIP_SUBTREE; } else { - parent = node; + m_parent = node; // If the current node has only leaf children, we can find the // desired node directly. This can speed up finding the node @@ -3500,8 +3497,8 @@ public: if ( node->HasChildren() && (int)node->GetChildNodes().size() == node->GetSubTreeCount() ) { - const int index = static_cast(row) - current - 1; - ret = node->GetChildNodes()[index]; + const int index = static_cast(m_row) - m_current - 1; + m_ret = node->GetChildNodes()[index]; return DoJob::DONE; } @@ -3510,13 +3507,13 @@ public: } wxDataViewTreeNode * GetResult() const - { return ret; } + { return m_ret; } private: - unsigned int row; - int current; - wxDataViewTreeNode * ret; - wxDataViewTreeNode * parent; + unsigned int m_row; + int m_current; + wxDataViewTreeNode* m_parent; + wxDataViewTreeNode* m_ret; }; wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) const From 3d4a47a6bbb1535c35319ac0f45c95b5a5057b59 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 14:56:36 +0100 Subject: [PATCH 012/140] Change RowToTreeNodeJob::m_row type to int and make it const It doesn't make much sense to use an "unsigned int" variable only to cast it to int everywhere where it's used. Just make it "int" from the get go and have a single cast to int in the caller. Also make m_row const as it never changes. --- src/generic/datavgen.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 1ad0120fb3..5965dae3ec 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3468,7 +3468,7 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const class RowToTreeNodeJob: public DoJob { public: - RowToTreeNodeJob(unsigned int row, int current, wxDataViewTreeNode *parent) + RowToTreeNodeJob(int row, int current, wxDataViewTreeNode *parent) : m_row(row), m_current(current), m_parent(parent), m_ret(NULL) { } @@ -3476,13 +3476,13 @@ public: virtual int operator() ( wxDataViewTreeNode * node ) wxOVERRIDE { m_current ++; - if( m_current == static_cast(m_row)) + if( m_current == m_row) { m_ret = node; return DoJob::DONE; } - if( node->GetSubTreeCount() + m_current < static_cast(m_row) ) + if( node->GetSubTreeCount() + m_current < m_row ) { m_current += node->GetSubTreeCount(); return DoJob::SKIP_SUBTREE; @@ -3497,7 +3497,7 @@ public: if ( node->HasChildren() && (int)node->GetChildNodes().size() == node->GetSubTreeCount() ) { - const int index = static_cast(m_row) - m_current - 1; + const int index = m_row - m_current - 1; m_ret = node->GetChildNodes()[index]; return DoJob::DONE; } @@ -3510,7 +3510,7 @@ public: { return m_ret; } private: - unsigned int m_row; + const int m_row; int m_current; wxDataViewTreeNode* m_parent; wxDataViewTreeNode* m_ret; @@ -3523,7 +3523,7 @@ wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) co if ( row == (unsigned)-1 ) return NULL; - RowToTreeNodeJob job( row , -2, m_root ); + RowToTreeNodeJob job( static_cast(row) , -2, m_root ); Walker( m_root , job ); return job.GetResult(); } From 739ce6055213d271b38c11b75c99afe4bf462c9d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 14:58:23 +0100 Subject: [PATCH 013/140] Remove the unused RowToTreeNodeJob::m_parent variable This variable was assigned to but never used. Also remove the corresponding ctor argument which was only used to initialize this unused variable. --- src/generic/datavgen.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 5965dae3ec..c83ce64821 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3468,8 +3468,8 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const class RowToTreeNodeJob: public DoJob { public: - RowToTreeNodeJob(int row, int current, wxDataViewTreeNode *parent) - : m_row(row), m_current(current), m_parent(parent), m_ret(NULL) + RowToTreeNodeJob(int row, int current) + : m_row(row), m_current(current), m_ret(NULL) { } @@ -3489,8 +3489,6 @@ public: } else { - m_parent = node; - // If the current node has only leaf children, we can find the // desired node directly. This can speed up finding the node // in some cases, and will have a very good effect for list views. @@ -3512,7 +3510,6 @@ public: private: const int m_row; int m_current; - wxDataViewTreeNode* m_parent; wxDataViewTreeNode* m_ret; }; @@ -3523,7 +3520,7 @@ wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) co if ( row == (unsigned)-1 ) return NULL; - RowToTreeNodeJob job( static_cast(row) , -2, m_root ); + RowToTreeNodeJob job( static_cast(row) , -2 ); Walker( m_root , job ); return job.GetResult(); } From 685f9ff57d87fdfdb3b9d84ed63f1ee37ad39d04 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:03:16 +0100 Subject: [PATCH 014/140] Fix bug in GetRowByItem() in generic wxDataViewCtrl If the item was not found at all, which can happen if all its parents are not expanded, this function still returned a valid but completely wrong row index. This affected many functions which could call it for the items which were not necessarily visible, i.e. all of them except for the event handlers as events can only affect the visible items, including but not limited to SetCurrentItem(), all the selection-related functions, all the expansion-related functions, EnsureVisible(), HitTest() and GetItemRect(). --- src/generic/datavgen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index c83ce64821..42e55ebb2e 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3920,7 +3920,9 @@ int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item) const // the parent chain was created by adding the deepest parent first. // so if we want to start at the root node, we have to iterate backwards through the vector ItemToRowJob job( item, parentChain.rbegin() ); - Walker( m_root, job ); + if ( !Walker( m_root, job ) ) + return -1; + return job.GetResult(); } } From 31c49caab51f086cf55a2b59fb2c03c1f5f8c25c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:10:23 +0100 Subject: [PATCH 015/140] Add unit test for wxDataViewCtrl::IsExpanded() Check that it returns correct results, both for the currently visible and hidden items. --- tests/controls/dataviewctrltest.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index d8b20740ed..338d00539c 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -84,7 +84,7 @@ DataViewCtrlTestCase::DataViewCtrlTestCase(long style) m_child2 = m_dvc->AppendItem(m_root, "child2"); m_dvc->SetSize(400, 200); - m_dvc->ExpandAncestors(m_root); + m_dvc->Expand(m_root); m_dvc->Refresh(); m_dvc->Update(); } @@ -188,4 +188,14 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, TestSelectionFor0and1(); } +TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, + "wxDVC::IsExpanded", + "[wxDataViewCtrl][expand]") +{ + CHECK( m_dvc->IsExpanded(m_root) ); + CHECK( !m_dvc->IsExpanded(m_child1) ); + CHECK( !m_dvc->IsExpanded(m_grandchild) ); + CHECK( !m_dvc->IsExpanded(m_child2) ); +} + #endif //wxUSE_DATAVIEWCTRL From ada5de3d0dcd2aa8a638ced4010b9b3a60aeff30 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:12:08 +0100 Subject: [PATCH 016/140] Fix wxDataViewCtrl::GetItemRect() for collapsed items Calling GetItemRect() for an item which was not currently visible because its parent was collapsed resulted in silently returning the value for a wrong value before the recent fix to GetRowByItem() and in a crash after it because GetTreeNodeByRow() returned null when passed invalid row index. Fix this by explicitly checking whether the item is shown and just returning an empty rectangle instead. Also document this behaviour and add a unit test for it. --- interface/wx/dataview.h | 9 +++++++-- src/generic/datavgen.cpp | 8 +++++++- tests/controls/dataviewctrltest.cpp | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 84c7479df8..1a8ab039ae 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -1446,8 +1446,13 @@ public: int GetIndent() const; /** - Returns item rectangle. Coordinates of the rectangle are specified in - wxDataViewCtrl client area coordinates. + Returns item rectangle. + + If item is not currently visible because its parent is collapsed, + return an empty rectangle. + + Coordinates of the rectangle are specified in wxDataViewCtrl client + area coordinates. @param item A valid item. diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 42e55ebb2e..d5a2fffd75 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3809,10 +3809,16 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, xpos = 0; } + const int row = GetRowByItem(item); + if ( row == -1 ) + { + // This means the row is currently not visible at all. + return wxRect(); + } + // we have to take an expander column into account and compute its indentation // to get the correct x position where the actual text is int indent = 0; - int row = GetRowByItem(item); if (!IsList() && (column == 0 || GetExpanderColumnOrFirstOne(GetOwner()) == column) ) { diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index 338d00539c..6d0d728890 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -198,4 +198,24 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, CHECK( !m_dvc->IsExpanded(m_child2) ); } +TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, + "wxDVC::GetItemRect", + "[wxDataViewCtrl][item]") +{ +#ifdef __WXGTK__ + WARN("Disabled under GTK because GetItemRect() is not implemented"); +#else + const wxRect rect1 = m_dvc->GetItemRect(m_child1); + const wxRect rect2 = m_dvc->GetItemRect(m_child2); + + CHECK( rect1.x == rect2.x ); + CHECK( rect1.width == rect2.width ); + CHECK( rect1.height == rect2.height ); + CHECK( rect1.y < rect2.y ); + + const wxRect rectNotShown = m_dvc->GetItemRect(m_grandchild); + CHECK( rectNotShown == wxRect() ); +#endif +} + #endif //wxUSE_DATAVIEWCTRL From ed204211810ac347082cb0ad0704acdbb18ee7b3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:16:31 +0100 Subject: [PATCH 017/140] Clarify RowToTreeNodeJob in generic wxDataViewCtrl code Get rid of hardcoded, without any explanation, "-2" value passed to this class ctor and instead initialize its m_current member to -1 and explain why do we do it and increment it after processing the current item, not before, in operator(). No changes in behaviour. --- src/generic/datavgen.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index d5a2fffd75..f2db03c189 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3468,14 +3468,16 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const class RowToTreeNodeJob: public DoJob { public: - RowToTreeNodeJob(int row, int current) - : m_row(row), m_current(current), m_ret(NULL) + // Note that we initialize m_current to -1 because the first node passed to + // our operator() will be the root node, which doesn't appear in the window + // and so doesn't count as a real row. + explicit RowToTreeNodeJob(int row) + : m_row(row), m_current(-1), m_ret(NULL) { } virtual int operator() ( wxDataViewTreeNode * node ) wxOVERRIDE { - m_current ++; if( m_current == m_row) { m_ret = node; @@ -3484,7 +3486,7 @@ public: if( node->GetSubTreeCount() + m_current < m_row ) { - m_current += node->GetSubTreeCount(); + m_current += node->GetSubTreeCount() + 1; return DoJob::SKIP_SUBTREE; } else @@ -3500,6 +3502,8 @@ public: return DoJob::DONE; } + m_current++; + return DoJob::CONTINUE; } } @@ -3520,7 +3524,7 @@ wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) co if ( row == (unsigned)-1 ) return NULL; - RowToTreeNodeJob job( static_cast(row) , -2 ); + RowToTreeNodeJob job(static_cast(row)); Walker( m_root , job ); return job.GetResult(); } From 1f0aad61e2597f849abb22809680a3741aa481ce Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:20:11 +0100 Subject: [PATCH 018/140] Use standard naming convention for ItemToRowJob members Use "m_" prefix for all of them. No real changes. --- src/generic/datavgen.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index f2db03c189..1d2f65d00f 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3860,18 +3860,16 @@ int wxDataViewMainWindow::RecalculateCount() const class ItemToRowJob : public DoJob { public: - ItemToRowJob(const wxDataViewItem& item_, wxVector::reverse_iterator iter) - : m_iter(iter), - item(item_) + ItemToRowJob(const wxDataViewItem& item, wxVector::reverse_iterator iter) + : m_item(item), m_iter(iter), m_ret(-1) { - ret = -1; } // Maybe binary search will help to speed up this process virtual int operator() ( wxDataViewTreeNode * node) wxOVERRIDE { - ret ++; - if( node->GetItem() == item ) + m_ret ++; + if( node->GetItem() == m_item ) { return DoJob::DONE; } @@ -3883,7 +3881,7 @@ public: } else { - ret += node->GetSubTreeCount(); + m_ret += node->GetSubTreeCount(); return DoJob::SKIP_SUBTREE; } @@ -3891,12 +3889,12 @@ public: // the row number is begin from zero int GetResult() const - { return ret -1; } + { return m_ret -1; } private: + wxDataViewItem m_item; wxVector::reverse_iterator m_iter; - wxDataViewItem item; - int ret; + int m_ret; }; From 4b8fed3ad62692aa04f3ccdce868f617ccf6f33a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:21:09 +0100 Subject: [PATCH 019/140] Make ItemToRowJob::m_item const No real changes, just indicate that this member variable doesn't change. --- src/generic/datavgen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 1d2f65d00f..994a70171e 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3892,7 +3892,7 @@ public: { return m_ret -1; } private: - wxDataViewItem m_item; + const wxDataViewItem m_item; wxVector::reverse_iterator m_iter; int m_ret; From c3779f2e5dcb6c57762d9347cce3c8e3cd372e19 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:29:24 +0100 Subject: [PATCH 020/140] Clarify ItemToRowJob in generic wxDataViewCtrl code Rename its m_ret field to a more clear and more consistent with RowToTreeNodeJob::m_current name and also make m_current, unlike m_ret, 0-based from the beginning instead of having to subtract 1 from it in GetResult(). There should be no changes in the class behaviour. --- src/generic/datavgen.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 994a70171e..d82c2f051f 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3860,41 +3860,49 @@ int wxDataViewMainWindow::RecalculateCount() const class ItemToRowJob : public DoJob { public: + // As with RowToTreeNodeJob above, we initialize m_current to -1 because + // the first node passed to our operator() is the root node which is not + // visible on screen and so we should return 0 for its first child node and + // not for the root itself. ItemToRowJob(const wxDataViewItem& item, wxVector::reverse_iterator iter) - : m_item(item), m_iter(iter), m_ret(-1) + : m_item(item), m_iter(iter), m_current(-1) { } // Maybe binary search will help to speed up this process virtual int operator() ( wxDataViewTreeNode * node) wxOVERRIDE { - m_ret ++; if( node->GetItem() == m_item ) { return DoJob::DONE; } + // Is this node the next (grand)parent of the item we're looking for? if( node->GetItem() == *m_iter ) { + // Search for the next (grand)parent now and skip this item itself. ++m_iter; + ++m_current; return DoJob::CONTINUE; } else { - m_ret += node->GetSubTreeCount(); + // Skip this node and all its currently visible children. + m_current += node->GetSubTreeCount() + 1; return DoJob::SKIP_SUBTREE; } } - // the row number is begin from zero int GetResult() const - { return m_ret -1; } + { return m_current; } private: const wxDataViewItem m_item; wxVector::reverse_iterator m_iter; - int m_ret; + + // The row corresponding to the last node seen in our operator(). + int m_current; }; From 9b7757c44db95514cdfdf96de731410bb31750b8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:49:12 +0100 Subject: [PATCH 021/140] Ensure that wxDataViewMainWindow has correct size in the test Replace a redundant (because the same size was already specified in the ctor) SetSize() call with a Layout() call which resizes wxDataViewMainWindow to fit the parent control size when using the generic implementation. This is important for any tests dealing with the control geometry, i.e. calling GetItemRect() or HitTest(). --- tests/controls/dataviewctrltest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index 6d0d728890..720fdce938 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -83,7 +83,7 @@ DataViewCtrlTestCase::DataViewCtrlTestCase(long style) m_grandchild = m_dvc->AppendItem(m_child1, "grandchild"); m_child2 = m_dvc->AppendItem(m_root, "child2"); - m_dvc->SetSize(400, 200); + m_dvc->Layout(); m_dvc->Expand(m_root); m_dvc->Refresh(); m_dvc->Update(); From 9460038b3ff1aa3767924b6ef44be4e0da7f9b39 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:50:55 +0100 Subject: [PATCH 022/140] Return empty rectangle from GetItemRect() if item is not visible This was already the case if the item was not visible because its parent was not expanded, but now make it also true for the items which are not visible due to the current scrollbar position. Add unit tests checking for this and also verifying that GetItemRect() returns the coordinates in the physical window coordinates. --- interface/wx/dataview.h | 5 +++-- src/generic/datavgen.cpp | 15 +++++++++++++-- tests/controls/dataviewctrltest.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 1a8ab039ae..85bc40acdb 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -1448,8 +1448,9 @@ public: /** Returns item rectangle. - If item is not currently visible because its parent is collapsed, - return an empty rectangle. + If item is not currently visible, either because its parent is + collapsed or it is outside of the visible part of the control due to + the current vertical scrollbar position, return an empty rectangle. Coordinates of the rectangle are specified in wxDataViewCtrl client area coordinates. diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index d82c2f051f..41c3b7fbed 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3839,6 +3839,14 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, GetOwner()->CalcScrolledPosition( itemRect.x, itemRect.y, &itemRect.x, &itemRect.y ); + // Check if the rectangle is completely outside of the currently visible + // area and, if so, return an empty rectangle to indicate that the item is + // not visible. + if ( itemRect.GetBottom() < 0 || itemRect.GetTop() > GetClientSize().y ) + { + return wxRect(); + } + return itemRect; } @@ -5853,8 +5861,11 @@ wxRect wxDataViewCtrl::GetItemRect( const wxDataViewItem & item, // Convert position from the main window coordinates to the control coordinates. // (They can be different due to the presence of the header.). wxRect r = m_clientArea->GetItemRect(item, column); - const wxPoint ctrlPos = ScreenToClient(m_clientArea->ClientToScreen(r.GetPosition())); - r.SetPosition(ctrlPos); + if ( r.width || r.height ) + { + const wxPoint ctrlPos = ScreenToClient(m_clientArea->ClientToScreen(r.GetPosition())); + r.SetPosition(ctrlPos); + } return r; } diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index 720fdce938..f7fcaca67e 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -208,6 +208,9 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, const wxRect rect1 = m_dvc->GetItemRect(m_child1); const wxRect rect2 = m_dvc->GetItemRect(m_child2); + CHECK( rect1 != wxRect() ); + CHECK( rect2 != wxRect() ); + CHECK( rect1.x == rect2.x ); CHECK( rect1.width == rect2.width ); CHECK( rect1.height == rect2.height ); @@ -215,6 +218,30 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, const wxRect rectNotShown = m_dvc->GetItemRect(m_grandchild); CHECK( rectNotShown == wxRect() ); + + // Append enough items to make the window scrollable. + for ( int i = 3; i < 100; ++i ) + m_dvc->AppendItem(m_root, wxString::Format("child%d", i)); + + const wxDataViewItem last = m_dvc->AppendItem(m_root, "last"); + + // This should scroll the window to bring this item into view. + m_dvc->EnsureVisible(last); + + // Check that this was indeed the case. + const wxDataViewItem top = m_dvc->GetTopItem(); + CHECK( top != m_root ); + + // Verify that the coordinates are returned in physical coordinates of the + // window and not the logical coordinates affected by scrolling. + const wxRect rectScrolled = m_dvc->GetItemRect(top); + CHECK( rectScrolled.GetBottom() > 0 ); + CHECK( rectScrolled.GetTop() <= m_dvc->GetClientSize().y ); + + // Also check that the root item is not currently visible (because it's + // scrolled off). + const wxRect rectRoot = m_dvc->GetItemRect(m_root); + CHECK( rectRoot == wxRect() ); #endif } From 9d2ee59138b298721f02ff90710d4354baef51ca Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 18:02:33 +0100 Subject: [PATCH 023/140] Update comments in tests/asserthelper.h No real changes, just avoid mentioning CPPUNIT_ASSERT_EQUAL() in the comments for the operator<<() overloads as it is used with CATCH too. Also don't duplicate the same comment 4 times unnecessarily. --- tests/asserthelper.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/asserthelper.h b/tests/asserthelper.h index ce8c9c6a29..ce1d1fba2a 100644 --- a/tests/asserthelper.h +++ b/tests/asserthelper.h @@ -29,16 +29,11 @@ namespace wxTestPrivate std::ostream& operator<<(std::ostream& os, const ColourChannel& cc); } // wxTestPrivate namespace -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxColour objects +// Operators used to show the values of the corresponding types when comparing +// them in the unit tests fails. std::ostream& operator<<(std::ostream& os, const wxColour& c); - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxSize objects std::ostream& operator<<(std::ostream& os, const wxSize& s); - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxFont objects std::ostream& operator<<(std::ostream& os, const wxFont& f); - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxPoint objects std::ostream& operator<<(std::ostream& os, const wxPoint& p); #endif From 12f8ab20f998cc70e1de6fb00b801401daf65848 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 18:05:25 +0100 Subject: [PATCH 024/140] Move operator<<(std::ostream&, wxRect) overload to a header This will allow reusing it in other tests too. Also make the output slightly more readable by formatting the rectangle as "{x,y w*h}" instead of "{x,y,w,h}". No real changes. --- tests/asserthelper.cpp | 8 ++++++++ tests/asserthelper.h | 1 + tests/geometry/rect.cpp | 13 +------------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/asserthelper.cpp b/tests/asserthelper.cpp index 8f9f36d452..7b25cec2d6 100644 --- a/tests/asserthelper.cpp +++ b/tests/asserthelper.cpp @@ -67,3 +67,11 @@ std::ostream& operator<<(std::ostream& os, const wxPoint& p) return os; } + +std::ostream& operator<<(std::ostream& os, const wxRect& r) +{ + os << "{" + << r.x << ", " << r.y << " " << r.width << "*" << r.height + << "}"; + return os; +} diff --git a/tests/asserthelper.h b/tests/asserthelper.h index ce1d1fba2a..57772453bb 100644 --- a/tests/asserthelper.h +++ b/tests/asserthelper.h @@ -35,5 +35,6 @@ std::ostream& operator<<(std::ostream& os, const wxColour& c); std::ostream& operator<<(std::ostream& os, const wxSize& s); std::ostream& operator<<(std::ostream& os, const wxFont& f); std::ostream& operator<<(std::ostream& os, const wxPoint& p); +std::ostream& operator<<(std::ostream& os, const wxRect& r); #endif diff --git a/tests/geometry/rect.cpp b/tests/geometry/rect.cpp index 07634a3ce6..94e67c9574 100644 --- a/tests/geometry/rect.cpp +++ b/tests/geometry/rect.cpp @@ -22,18 +22,7 @@ #include "wx/iosfwrap.h" -// ---------------------------------------------------------------------------- -// helper functions -// ---------------------------------------------------------------------------- - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxRects -std::ostream& operator<<(std::ostream& os, const wxRect& r) -{ - os << "{" - << r.x << ", " << r.y << ", " << r.width << ", " << r.height - << "}"; - return os; -} +#include "asserthelper.h" // ---------------------------------------------------------------------------- // test class From 94a2595f5b53cca321c28447c8857308a965d165 Mon Sep 17 00:00:00 2001 From: Umberto Carletti Date: Mon, 22 Oct 2018 10:13:34 +0200 Subject: [PATCH 025/140] Add GTK implementation of wxDataViewCtrl::GetItemRect() This function returns a wxRect of the given wxDataViewItem. If no column is provided, the width will be the sum of all the visible columns widths. See https://github.com/wxWidgets/wxWidgets/pull/990 --- src/gtk/dataview.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 8e1a6503a3..c5662aa26e 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -5289,10 +5289,36 @@ void wxDataViewCtrl::HitTest(const wxPoint& point, } wxRect -wxDataViewCtrl::GetItemRect(const wxDataViewItem& WXUNUSED(item), - const wxDataViewColumn *WXUNUSED(column)) const +wxDataViewCtrl::GetItemRect(const wxDataViewItem& item, + const wxDataViewColumn *column) const { - return wxRect(); + if ( !item ) + return wxRect(); + + GtkTreeViewColumn *gcolumn = NULL ; + if (column) + gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle()); + + GtkTreeIter iter; + iter.user_data = item.GetID(); + wxGtkTreePath path(m_internal->get_path( &iter )); + + GdkRectangle item_rect; + gtk_tree_view_get_background_area(GTK_TREE_VIEW(m_treeview), path, gcolumn, &item_rect); + // If column is NULL we compute the combined width of all the columns + if ( !column ) + { + unsigned int cols = GetColumnCount(); + int width = 0; + for (unsigned int i = 0; i < cols; ++i) + { + wxDataViewColumn * col = GetColumn(i); + if ( !col->IsHidden() ) + width += col->GetWidth(); + } + item_rect.width = width; + } + return wxRectFromGDKRect(&item_rect); } bool wxDataViewCtrl::SetRowHeight(int rowHeight) From fad50e74b7737708233cf6fcc2f374d69c79b923 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 18:25:16 +0100 Subject: [PATCH 026/140] Fix wxDataViewCtrl::GetItemRect() in wxGTK and enable its test A couple of fixes compared to the previous commit: - Use the correct gtk_tree_view_get_cell_area() rather than gtk_tree_view_get_background_area() which doesn't work correctly for the items which are not shown because their parent is collapsed. - Translate logical coordinates to physical ones using gtk_tree_view_convert_bin_window_to_widget_coords(). With these fixes, the unit tests for this function pass and can now be enabled under wxGTK as well. See https://github.com/wxWidgets/wxWidgets/pull/990 --- src/gtk/dataview.cpp | 37 ++++++++++++++++++++++++++++- tests/controls/dataviewctrltest.cpp | 19 +++++++++++---- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index c5662aa26e..d2c1abf352 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -5304,7 +5304,15 @@ wxDataViewCtrl::GetItemRect(const wxDataViewItem& item, wxGtkTreePath path(m_internal->get_path( &iter )); GdkRectangle item_rect; - gtk_tree_view_get_background_area(GTK_TREE_VIEW(m_treeview), path, gcolumn, &item_rect); + gtk_tree_view_get_cell_area(GTK_TREE_VIEW(m_treeview), path, gcolumn, &item_rect); + + // GTK returns rectangles with the position and height, but not width, for + // some reason, set to 0 if the item is not currently shown, so an explicit + // check is needed as this rectangle is not quite the empty rectangle we're + // supposed to return in this case. + if ( item_rect.height == 0 ) + return wxRect(); + // If column is NULL we compute the combined width of all the columns if ( !column ) { @@ -5318,6 +5326,33 @@ wxDataViewCtrl::GetItemRect(const wxDataViewItem& item, } item_rect.width = width; } + + // We need to convert logical coordinates to physical ones, i.e. the + // rectangle of the topmost item should start at ~0, even if it's a 100th + // item shown on top only because the window is scrolled. +#if GTK_CHECK_VERSION(2, 12, 0) + if ( wx_is_at_least_gtk2(12) ) + { + gtk_tree_view_convert_bin_window_to_widget_coords + ( + GTK_TREE_VIEW(m_treeview), + item_rect.x, item_rect.y, + &item_rect.x, &item_rect.y + ); + + if ( item_rect.y > GetClientSize().y || + item_rect.y + item_rect.height < 0 ) + { + // If it turns out that the item is not visible at all, indicate it + // by returning an empty rectangle for it. + return wxRect(); + } + } + //else: There doesn't seem to be anything reasonable to do here, so we'll + // just return wrong values with the very old GTK+ versions if the + // window is scrolled. +#endif // GTK+ 2.12+ + return wxRectFromGDKRect(&item_rect); } diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index f7fcaca67e..0f99eecfbe 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -22,6 +22,7 @@ #include "wx/dataview.h" #include "testableframe.h" +#include "asserthelper.h" // ---------------------------------------------------------------------------- // test class @@ -203,8 +204,10 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, "[wxDataViewCtrl][item]") { #ifdef __WXGTK__ - WARN("Disabled under GTK because GetItemRect() is not implemented"); -#else + // We need to let the native control have some events to lay itself out. + wxYield(); +#endif // __WXGTK__ + const wxRect rect1 = m_dvc->GetItemRect(m_child1); const wxRect rect2 = m_dvc->GetItemRect(m_child2); @@ -214,7 +217,11 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, CHECK( rect1.x == rect2.x ); CHECK( rect1.width == rect2.width ); CHECK( rect1.height == rect2.height ); - CHECK( rect1.y < rect2.y ); + + { + INFO("First child: " << rect1 << ", second one: " << rect2); + CHECK( rect1.y < rect2.y ); + } const wxRect rectNotShown = m_dvc->GetItemRect(m_grandchild); CHECK( rectNotShown == wxRect() ); @@ -228,6 +235,11 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, // This should scroll the window to bring this item into view. m_dvc->EnsureVisible(last); +#ifdef __WXGTK__ + // And again to let it scroll the correct items into view. + wxYield(); +#endif + // Check that this was indeed the case. const wxDataViewItem top = m_dvc->GetTopItem(); CHECK( top != m_root ); @@ -242,7 +254,6 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, // scrolled off). const wxRect rectRoot = m_dvc->GetItemRect(m_root); CHECK( rectRoot == wxRect() ); -#endif } #endif //wxUSE_DATAVIEWCTRL From bf97715972fb05adf2df10c27571dd1e1b62f1c3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 18:35:07 +0100 Subject: [PATCH 027/140] Support NULL column in wxDataViewCtrl::GetItemRect() in wxOSX Emulate support for non-specified column by using the first and, if necessary, last columns in this case. --- interface/wx/dataview.h | 4 +--- src/osx/dataview_osx.cpp | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 85bc40acdb..a001760b05 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -1462,9 +1462,7 @@ public: intersection of the item with the specified column. If @NULL, the rectangle spans all the columns. - @note This method is currently not implemented at all in wxGTK and only - implemented for non-@NULL @a col argument in wxOSX. It is fully - implemented in the generic version of the control. + @note This method is currently not implemented in wxGTK. */ virtual wxRect GetItemRect(const wxDataViewItem& item, const wxDataViewColumn* col = NULL) const; diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index f49a360dc6..57a1cf3970 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -547,10 +547,24 @@ wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const { - if (item.IsOk() && (columnPtr != NULL)) - return GetDataViewPeer()->GetRectangle(item,columnPtr); - else - return wxRect(); + if ( !item.IsOk() ) + return wxRect(); + + wxRect rect = GetDataViewPeer()->GetRectangle(item, columnPtr ? columnPtr : GetColumn(0)); + + if ( !columnPtr ) + { + const unsigned columnCount = GetColumnCount(); + if ( columnCount != 1 ) + { + // Extend the rectangle to the rightmost part of the last column. + const wxRect rectLastCol = GetDataViewPeer()->GetRectangle(item, GetColumn(columnCount - 1)); + rect.SetRight(rectLastCol.GetRight()); + } + //else: We already have the rectangle we need. + } + + return rect; } int wxDataViewCtrl::GetSelectedItemsCount() const From 1256695d46bc683cb3fc1311809823c191886a9e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 18:37:54 +0100 Subject: [PATCH 028/140] Document that wxDataViewCtrl::GetItemRect() now works in wxGTK Remove the note about it being non-implemented from the docs and mention this in the change log. --- docs/changes.txt | 1 + interface/wx/dataview.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 25d36877e0..e5ff0d7536 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -141,6 +141,7 @@ wxGTK: - Fix the build with glib < 2.32 (e.g. CentOS 6). - Fix field widths in wxStatusBar showing a size grip. - Fill column value in wxEVT_DATAVIEW_ITEM_ACTIVATED events. +- Implement wxDataViewCtrl::GetItemRect() (MrMeesek). wxMSW: diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index a001760b05..06a662722d 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -1461,8 +1461,6 @@ public: If non-@NULL, the rectangle returned corresponds to the intersection of the item with the specified column. If @NULL, the rectangle spans all the columns. - - @note This method is currently not implemented in wxGTK. */ virtual wxRect GetItemRect(const wxDataViewItem& item, const wxDataViewColumn* col = NULL) const; From 291a880d0c2babbc05f0d0c4d77af9a511c11b37 Mon Sep 17 00:00:00 2001 From: Mick Phillips Date: Mon, 5 Nov 2018 16:37:53 +0000 Subject: [PATCH 029/140] Synchronize joystick events between all ports Generate wxJoystickEvent with the same fields under all platforms by making the Linux and macOS versions follow MSW convention of using "1 << N" for the changed button. Add GetButtonOrdinal() accessor which can be used to retrieve just N. Closes #18233. --- include/wx/event.h | 2 ++ include/wx/math.h | 10 ++++++++++ interface/wx/event.h | 16 +++++++++++++++- samples/joytest/joytest.cpp | 2 +- src/common/utilscmn.cpp | 23 +++++++++++++++++++++++ src/msw/joystick.cpp | 23 +++-------------------- src/osx/core/hidjoystick.cpp | 2 +- src/unix/joystick.cpp | 4 ++-- 8 files changed, 57 insertions(+), 25 deletions(-) diff --git a/include/wx/event.h b/include/wx/event.h index d2b7a5d932..20f08b1ae2 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -15,6 +15,7 @@ #include "wx/cpp.h" #include "wx/object.h" #include "wx/clntdata.h" +#include "wx/math.h" #if wxUSE_GUI #include "wx/gdicmn.h" @@ -2760,6 +2761,7 @@ public: int GetZPosition() const { return m_zPosition; } int GetButtonState() const { return m_buttonState; } int GetButtonChange() const { return m_buttonChange; } + int GetButtonOrdinal() const { return wxCTZ(m_buttonChange); } int GetJoystick() const { return m_joyStick; } void SetJoystick(int stick) { m_joyStick = stick; } diff --git a/include/wx/math.h b/include/wx/math.h index 544b5c7d6e..8f5e9ddc56 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -181,4 +181,14 @@ inline double wxRadToDeg(double rad) { return (rad * 180.0) / M_PI; } /* Compute the greatest common divisor of two positive integers */ WXDLLIMPEXP_BASE unsigned int wxGCD(unsigned int u, unsigned int v); +#ifdef __cplusplus +/* Count trailing zeros + +Returns the number of trailing zeros in unsigned input x. + +@since 3.1.2 +*/ +WXDLLIMPEXP_BASE unsigned int wxCTZ(unsigned x); +#endif + #endif /* _WX_MATH_H_ */ diff --git a/interface/wx/event.h b/interface/wx/event.h index b58fdc4a3c..38261d1db1 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -1741,10 +1741,24 @@ public: /** Returns the identifier of the button changing state. - This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4. + The return value is @code 1 << n @endcode where @c n is the index of the + button changing state. + + Note that for @c n equal to 1, 2, 3 or 4 there are predefined @c wxJOY_BUTTONn + constants which can be used for more clarity, however these constants are not + defined for the buttons beyond the first four. + and whose values were 1 << n. To support more than four buttons, the return value + is now defined as 1 << n. */ int GetButtonChange() const; + /** + Returns the 0-indexed ordinal of the button changing state. + + @since 3.1.2. + */ + int GetButtonOrdinal() const; + /** Returns the down state of the buttons. diff --git a/samples/joytest/joytest.cpp b/samples/joytest/joytest.cpp index dd62713eec..c355d05fe6 100644 --- a/samples/joytest/joytest.cpp +++ b/samples/joytest/joytest.cpp @@ -159,7 +159,7 @@ void MyCanvas::OnJoystickEvent(wxJoystickEvent& event) #if wxUSE_STATUSBAR wxString buf; if (event.ButtonDown()) - buf.Printf("Joystick (%ld, %ld) #%i Fire!", xpos, ypos, event.GetButtonChange()); + buf.Printf("Joystick (%ld, %ld) #%i Fire!", xpos, ypos, event.GetButtonOrdinal()); else buf.Printf("Joystick (%ld, %ld) ", xpos, ypos); diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index f18f5f1fb2..23324e28e6 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -19,6 +19,8 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include "wx/debug.h" + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -1015,6 +1017,27 @@ unsigned int wxGCD(unsigned int u, unsigned int v) return u << shift; } +// ---------------------------------------------------------------------------- +// wxCTZ +// Count trailing zeros. Use optimised builtin where available. +// ---------------------------------------------------------------------------- +unsigned int wxCTZ(unsigned x) +{ + wxCHECK_MSG(x > 0, 0, "Undefined for x == 0."); +#ifdef __GNUC__ + return __builtin_ctz(x); +#else + int n; + n = 1; + if ((x & 0x0000FFFF) == 0) {n = n +16; x = x >>16;} + if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;} + if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;} + if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;} + return n - (x & 1); +#endif +} + + #endif // wxUSE_BASE // ============================================================================ diff --git a/src/msw/joystick.cpp b/src/msw/joystick.cpp index 3290460ab6..b53aeb6d23 100644 --- a/src/msw/joystick.cpp +++ b/src/msw/joystick.cpp @@ -37,23 +37,6 @@ #include -// Use optimised count trailing zeros where available. -static int wxCtz(unsigned x) -{ - wxCHECK_MSG(x > 0, 0, "Undefined for x == 0."); -#ifdef __GNUC__ - return __builtin_ctz(x); -#else - int n; - n = 1; - if ((x & 0x0000FFFF) == 0) {n = n +16; x = x >>16;} - if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;} - if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;} - if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;} - return n - (x & 1); -#endif -} - enum { wxJS_AXIS_X = 0, @@ -90,7 +73,7 @@ public: private: void SendEvent(wxEventType type, long ts, int change = 0); int m_joystick; - UINT m_buttons; + int m_buttons; wxWindow* m_catchwin; int m_polling; JOYINFO m_joyInfo; @@ -141,9 +124,9 @@ void* wxJoystickThread::Entry() // "Current button number that is pressed.", but it turns out // it is the *total* number of buttons pressed. if (deltaUp) - SendEvent(wxEVT_JOY_BUTTON_UP, ts, wxCtz(deltaUp)+1); + SendEvent(wxEVT_JOY_BUTTON_UP, ts, deltaUp); if (deltaDown) - SendEvent(wxEVT_JOY_BUTTON_DOWN, ts, wxCtz(deltaDown)+1); + SendEvent(wxEVT_JOY_BUTTON_DOWN, ts, deltaDown); if ((m_joyInfo.wXpos != m_lastJoyInfo.wXpos) || (m_joyInfo.wYpos != m_lastJoyInfo.wYpos) || diff --git a/src/osx/core/hidjoystick.cpp b/src/osx/core/hidjoystick.cpp index feace2517e..cf47209311 100644 --- a/src/osx/core/hidjoystick.cpp +++ b/src/osx/core/hidjoystick.cpp @@ -872,7 +872,7 @@ void* wxJoystickThread::Entry() wxevent.SetEventType(wxEVT_JOY_BUTTON_UP); } - wxevent.SetButtonChange(nIndex+1); + wxevent.SetButtonChange(1 << nIndex); } else if (nIndex == wxJS_AXIS_X) { diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index 928e9f6fc9..0e51fd5ca6 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -181,12 +181,12 @@ void* wxJoystickThread::Entry() if (j_evt.value) { m_buttons |= (1 << j_evt.number); - SendEvent(wxEVT_JOY_BUTTON_DOWN, j_evt.time, j_evt.number); + SendEvent(wxEVT_JOY_BUTTON_DOWN, j_evt.time, 1 << j_evt.number); } else { m_buttons &= ~(1 << j_evt.number); - SendEvent(wxEVT_JOY_BUTTON_UP, j_evt.time, j_evt.number); + SendEvent(wxEVT_JOY_BUTTON_UP, j_evt.time, 1 << j_evt.number); } } } From 41981070861e16bb86c8957ce237642a9764b572 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Nov 2018 19:17:12 +0100 Subject: [PATCH 030/140] Fix wxJoystickEvent documentation after the last commit Remove left over part of the old sentence. Also add a link to GetButtonChange() to GetButtonOrdinal() documentation. --- interface/wx/event.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/wx/event.h b/interface/wx/event.h index 38261d1db1..061ba76201 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -1742,19 +1742,19 @@ public: Returns the identifier of the button changing state. The return value is @code 1 << n @endcode where @c n is the index of the - button changing state. - + button changing state, which can also be retrieved using GetButtonOrdinal(). + Note that for @c n equal to 1, 2, 3 or 4 there are predefined @c wxJOY_BUTTONn constants which can be used for more clarity, however these constants are not defined for the buttons beyond the first four. - and whose values were 1 << n. To support more than four buttons, the return value - is now defined as 1 << n. */ int GetButtonChange() const; /** Returns the 0-indexed ordinal of the button changing state. - + + @see GetButtonChange() + @since 3.1.2. */ int GetButtonOrdinal() const; From b00a24af60c99d9861af2cba25e4501175b0e554 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Nov 2018 19:18:11 +0100 Subject: [PATCH 031/140] Document wxJoystickEvent event changes In particular, list the incompatible change in the corresponding section and explain how to update the existing code. --- docs/changes.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 25d36877e0..840417ab50 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -54,6 +54,12 @@ Changes in behaviour not resulting in compilation errors - wxEVT_AUINOTEBOOK_PAGE_CHANGED event is now sent after changing the page, as expected, and not before doing it. +- wxJoystickEvent::GetButtonChange() now returns "1 << N" for the events + generated by the button number N under all platforms, whereas it used to + return just "N" under Linux and macOS. Use the new GetButtonOrdinal() to + update the existing code if necessary. + + Changes in behaviour which may result in build errors ----------------------------------------------------- @@ -131,6 +137,7 @@ All (GUI): - Add wxGrid::SetCornerLabelValue() (Pavel Kalugin). - Add strikethrough support for fonts defined in XRC. - Add wxDisplay::GetPPI(). +- Add wxJoystickEvent::GetButtonOrdinal() (Mick Phillips). wxGTK: From 1c68979fb4b147d58b5430e110cb1dece6eb122a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Nov 2018 19:19:18 +0100 Subject: [PATCH 032/140] Move wxCTZ() documentation to the appropriate place The documentation comment belongs to interface/wx/math.h, not the header under include. Also change the argument type to wxUint32 as the non-gcc version only works for 32 bit values. --- include/wx/math.h | 13 +++---------- interface/wx/math.h | 13 +++++++++++++ src/common/utilscmn.cpp | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/wx/math.h b/include/wx/math.h index 8f5e9ddc56..261969d364 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -150,6 +150,9 @@ inline int wxRound(double x) inline double wxDegToRad(double deg) { return (deg * M_PI) / 180.0; } inline double wxRadToDeg(double rad) { return (rad * 180.0) / M_PI; } +// Count trailing zeros. +WXDLLIMPEXP_BASE unsigned int wxCTZ(wxUint32 x); + #endif /* __cplusplus */ @@ -181,14 +184,4 @@ inline double wxRadToDeg(double rad) { return (rad * 180.0) / M_PI; } /* Compute the greatest common divisor of two positive integers */ WXDLLIMPEXP_BASE unsigned int wxGCD(unsigned int u, unsigned int v); -#ifdef __cplusplus -/* Count trailing zeros - -Returns the number of trailing zeros in unsigned input x. - -@since 3.1.2 -*/ -WXDLLIMPEXP_BASE unsigned int wxCTZ(unsigned x); -#endif - #endif /* _WX_MATH_H_ */ diff --git a/interface/wx/math.h b/interface/wx/math.h index ca11a9fff2..b1486c270c 100644 --- a/interface/wx/math.h +++ b/interface/wx/math.h @@ -75,6 +75,19 @@ double wxDegToRad(double deg); */ double wxRadToDeg(double rad); +/** + Count the number of trailing zeros. + + This function returns the number of trailing zeros in the binary notation + of its argument @a x. E.g. for @a x equal to 4, or 0b100, the return value + is 2. + + @param x Strictly positive, i.e. non-zero, 32 bit number. + + @since 3.1.2 + */ +unsigned int wxCTZ(wxUint32 x); + /** Small wrapper around round(). */ diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 23324e28e6..456dc1b38a 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -1021,7 +1021,7 @@ unsigned int wxGCD(unsigned int u, unsigned int v) // wxCTZ // Count trailing zeros. Use optimised builtin where available. // ---------------------------------------------------------------------------- -unsigned int wxCTZ(unsigned x) +unsigned int wxCTZ(wxUint32 x) { wxCHECK_MSG(x > 0, 0, "Undefined for x == 0."); #ifdef __GNUC__ From ef92b926911321252a26ae2ad8df291caeef5ed0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Nov 2018 19:23:53 +0100 Subject: [PATCH 033/140] Add unit test for wxCTZ Check that the new function works reasonably correctly. --- tests/misc/misctests.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/misc/misctests.cpp b/tests/misc/misctests.cpp index b6dd757513..c6f1a0f64b 100644 --- a/tests/misc/misctests.cpp +++ b/tests/misc/misctests.cpp @@ -19,6 +19,8 @@ #include "wx/defs.h" +#include "wx/math.h" + // just some classes using wxRTTI for wxStaticCast() test #include "wx/tarstrm.h" #include "wx/zipstrm.h" @@ -150,3 +152,12 @@ void MiscTestCase::StaticCast() #endif // wxUSE_TARSTREAM } +TEST_CASE("wxCTZ", "[math]") +{ + CHECK( wxCTZ(1) == 0 ); + CHECK( wxCTZ(4) == 2 ); + CHECK( wxCTZ(17) == 0 ); + CHECK( wxCTZ(0x80000000) == 31 ); + + WX_ASSERT_FAILS_WITH_ASSERT( wxCTZ(0) ); +} From 5e53b22bd4fc7c6a196d14c75b404c56d5af577e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Nov 2018 03:17:49 +0100 Subject: [PATCH 034/140] Add wxGraphicsContext::GetWindow() This method allows to retrieve the window this context is associated with, if any. Add "wxWindow*" argument to wxGraphicsContext ctor and provide the window pointer to it when available, i.e. when creating the context from a wxWindow directly or from wxWindowDC, which is also associated with a window, in platform-specific code. No real changes yet. --- docs/changes.txt | 1 + include/wx/graphics.h | 11 ++++++++- interface/wx/graphics.h | 13 ++++++++++ src/common/graphcmn.cpp | 8 ++++--- src/generic/graphicc.cpp | 4 ++-- src/msw/graphics.cpp | 12 ++++++---- src/msw/graphicsd2d.cpp | 47 +++++++++++++++++++++++++++---------- src/osx/carbon/graphics.cpp | 45 ++++++++++++++++++----------------- 8 files changed, 96 insertions(+), 45 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f35cb268d6..d59874488b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -128,6 +128,7 @@ All (GUI): - Add wxGrid::SetCornerLabelValue() (Pavel Kalugin). - Add strikethrough support for fonts defined in XRC. - Add wxDisplay::GetPPI(). +- Add wxGraphicsContext::GetWindow(). wxGTK: diff --git a/include/wx/graphics.h b/include/wx/graphics.h index 9141d39450..a35667491f 100644 --- a/include/wx/graphics.h +++ b/include/wx/graphics.h @@ -452,7 +452,7 @@ private: class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject { public: - wxGraphicsContext(wxGraphicsRenderer* renderer); + wxGraphicsContext(wxGraphicsRenderer* renderer, wxWindow* window = NULL); virtual ~wxGraphicsContext(); @@ -490,6 +490,9 @@ public: // create a context that can be used for measuring texts only, no drawing allowed static wxGraphicsContext * Create(); + // Return the window this context is associated with, if any. + wxWindow* GetWindow() const { return m_window; } + // begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown virtual bool StartDoc( const wxString& message ); @@ -788,6 +791,12 @@ protected: wxDouble angle, const wxGraphicsBrush& backgroundBrush); +private: + // The associated window, if any, i.e. if one was passed directly to + // Create() or the associated window of the wxDC this context was created + // from. + wxWindow* const m_window; + wxDECLARE_NO_COPY_CLASS(wxGraphicsContext); wxDECLARE_ABSTRACT_CLASS(wxGraphicsContext); }; diff --git a/interface/wx/graphics.h b/interface/wx/graphics.h index 2e1bd40477..5154ec19ba 100644 --- a/interface/wx/graphics.h +++ b/interface/wx/graphics.h @@ -1095,6 +1095,19 @@ public: */ virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY); + /** + Returns the associated window if any. + + If this context was created using Create() overload taking wxWindow or + wxWindowDC, this method returns the corresponding window. Otherwise + returns @NULL. + + @return A possibly @NULL window pointer. + + @since 3.1.2 + */ + wxWindow* GetWindow() const; + /** @} */ diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index fc0e6ab894..006db0586e 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -565,12 +565,14 @@ void * wxGraphicsBitmap::GetNativeBitmap() const wxIMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext, wxObject); -wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer) : - wxGraphicsObject(renderer), +wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer, + wxWindow* window) + : wxGraphicsObject(renderer), m_antialias(wxANTIALIAS_DEFAULT), m_composition(wxCOMPOSITION_OVER), m_interpolation(wxINTERPOLATION_DEFAULT), - m_enableOffset(false) + m_enableOffset(false), + m_window(window) { } diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 7ed04b4bd4..ebebea96df 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -1830,7 +1830,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC& #endif wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ) -: wxGraphicsContext(renderer) +: wxGraphicsContext(renderer, dc.GetWindow()) { int width, height; dc.GetSize( &width, &height ); @@ -2244,7 +2244,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context ) } wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window) - : wxGraphicsContext(renderer) + : wxGraphicsContext(renderer, window) #ifdef __WXMSW__ , m_mswWindowHDC(GetHwndOf(window)) #endif diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 04cca9d732..ebecbeb72a 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -358,7 +358,7 @@ class wxGDIPlusContext : public wxGraphicsContext public: wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc ); wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDouble width, wxDouble height ); - wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd ); + wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd, wxWindow* window = NULL); wxGDIPlusContext( wxGraphicsRenderer* renderer, Graphics* gr); wxGDIPlusContext(wxGraphicsRenderer* renderer); @@ -1647,7 +1647,7 @@ wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDou } wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc ) - : wxGraphicsContext(renderer) + : wxGraphicsContext(renderer, dc.GetWindow()) { wxMSWDCImpl *msw = wxDynamicCast( dc.GetImpl() , wxMSWDCImpl ); HDC hdc = (HDC) msw->GetHDC(); @@ -1656,8 +1656,10 @@ wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc Init(new Graphics(hdc), sz.x, sz.y); } -wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd ) - : wxGraphicsContext(renderer) +wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, + HWND hwnd, + wxWindow* window ) + : wxGraphicsContext(renderer, window) { RECT rect = wxGetWindowRect(hwnd); Init(new Graphics(hwnd), rect.right - rect.left, rect.bottom - rect.top); @@ -2492,7 +2494,7 @@ wxGraphicsContext * wxGDIPlusRenderer::CreateContextFromNativeHDC(WXHDC dc) wxGraphicsContext * wxGDIPlusRenderer::CreateContext( wxWindow* window ) { ENSURE_LOADED_OR_RETURN(NULL); - return new wxGDIPlusContext(this, (HWND) window->GetHWND() ); + return new wxGDIPlusContext(this, (HWND) window->GetHWND(), window ); } // Path diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 00eb65dde3..eccdf77122 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -3400,9 +3400,19 @@ public: class wxD2DContext : public wxGraphicsContext, wxD2DResourceManager { public: - wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HWND hwnd); + // Create the context for the given HWND, which may be associated (if it's + // non-null) with the given wxWindow. + wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HWND hwnd, + wxWindow* window = NULL); - wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HDC hdc, const wxSize& dcSize, + // Create the context for the given HDC which may be associated (if it's + // non-null) with the given wxDC. + wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HDC hdc, + const wxDC* dc = NULL, D2D1_ALPHA_MODE alphaMode = D2D1_ALPHA_MODE_IGNORE); #if wxUSE_IMAGE @@ -3550,8 +3560,11 @@ private: // wxD2DContext implementation //----------------------------------------------------------------------------- -wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HWND hwnd) : - wxGraphicsContext(renderer), m_direct2dFactory(direct2dFactory), +wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HWND hwnd, + wxWindow* window) : + wxGraphicsContext(renderer, window), m_direct2dFactory(direct2dFactory), #if wxD2D_DEVICE_CONTEXT_SUPPORTED m_renderTargetHolder(new wxD2DDeviceContextResourceHolder(direct2dFactory, hwnd)) #else @@ -3564,13 +3577,21 @@ wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dF Init(); } -wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HDC hdc, - const wxSize& dcSize, D2D1_ALPHA_MODE alphaMode) : - wxGraphicsContext(renderer), m_direct2dFactory(direct2dFactory), +wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HDC hdc, + const wxDC* dc, + D2D1_ALPHA_MODE alphaMode) : + wxGraphicsContext(renderer, dc->GetWindow()), m_direct2dFactory(direct2dFactory), m_renderTargetHolder(new wxD2DDCRenderTargetResourceHolder(direct2dFactory, hdc, alphaMode)) { - m_width = dcSize.GetWidth(); - m_height = dcSize.GetHeight(); + if ( dc ) + { + const wxSize dcSize = dc->GetSize(); + m_width = dcSize.GetWidth(); + m_height = dcSize.GetHeight(); + } + Init(); } @@ -4531,7 +4552,7 @@ wxD2DRenderer::~wxD2DRenderer() wxGraphicsContext* wxD2DRenderer::CreateContext(const wxWindowDC& dc) { - return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), dc.GetSize()); + return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), &dc); } wxGraphicsContext* wxD2DRenderer::CreateContext(const wxMemoryDC& dc) @@ -4539,7 +4560,7 @@ wxGraphicsContext* wxD2DRenderer::CreateContext(const wxMemoryDC& dc) wxBitmap bmp = dc.GetSelectedBitmap(); wxASSERT_MSG( bmp.IsOk(), wxS("Should select a bitmap before creating wxGraphicsContext") ); - return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), dc.GetSize(), + return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), &dc, bmp.HasAlpha() ? D2D1_ALPHA_MODE_PREMULTIPLIED : D2D1_ALPHA_MODE_IGNORE); } @@ -4571,12 +4592,12 @@ wxGraphicsContext* wxD2DRenderer::CreateContextFromNativeWindow(void* window) wxGraphicsContext* wxD2DRenderer::CreateContextFromNativeHDC(WXHDC dc) { - return new wxD2DContext(this, m_direct2dFactory, (HDC)dc, wxSize(0, 0)); + return new wxD2DContext(this, m_direct2dFactory, (HDC)dc); } wxGraphicsContext* wxD2DRenderer::CreateContext(wxWindow* window) { - return new wxD2DContext(this, m_direct2dFactory, (HWND)window->GetHWND()); + return new wxD2DContext(this, m_direct2dFactory, (HWND)window->GetHWND(), window); } #if wxUSE_IMAGE diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 16f58329da..c8f96aa43f 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -1303,7 +1303,11 @@ bool wxMacCoreGraphicsPathData::Contains( wxDouble x, wxDouble y, wxPolygonFillM class WXDLLEXPORT wxMacCoreGraphicsContext : public wxGraphicsContext { public: - wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, CGContextRef cgcontext, wxDouble width = 0, wxDouble height = 0 ); + wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, + CGContextRef cgcontext, + wxDouble width = 0, + wxDouble height = 0, + wxWindow* window = NULL ); wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, wxWindow* window ); @@ -1509,7 +1513,12 @@ void wxMacCoreGraphicsContext::Init() m_interpolation = wxINTERPOLATION_DEFAULT; } -wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, CGContextRef cgcontext, wxDouble width, wxDouble height ) : wxGraphicsContext(renderer) +wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, + CGContextRef cgcontext, + wxDouble width, + wxDouble height, + wxWindow* window ) + : wxGraphicsContext(renderer, window) { Init(); SetNativeContext(cgcontext); @@ -1518,7 +1527,9 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer m_initTransform = m_cgContext ? CGContextGetCTM(m_cgContext) : CGAffineTransformIdentity; } -wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, wxWindow* window ): wxGraphicsContext(renderer) +wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, + wxWindow* window ) + : wxGraphicsContext(renderer, window) { Init(); @@ -2694,26 +2705,18 @@ wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer() wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc ) { - const wxDCImpl* impl = dc.GetImpl(); - wxWindowDCImpl *win_impl = wxDynamicCast( impl, wxWindowDCImpl ); - if (win_impl) - { - int w, h; - win_impl->GetSize( &w, &h ); - CGContextRef cgctx = 0; + wxWindow* const win = dc.GetWindow(); + wxCHECK_MSG( win, NULL, "Invalid wxWindowDC" ); - wxASSERT_MSG(win_impl->GetWindow(), "Invalid wxWindow in wxMacCoreGraphicsRenderer::CreateContext"); - if (win_impl->GetWindow()) - cgctx = (CGContextRef)(win_impl->GetWindow()->MacGetCGContextRef()); + const wxSize sz = win->GetSize(); - // having a cgctx being NULL is fine (will be created on demand) - // this is the case for all wxWindowDCs except wxPaintDC - wxMacCoreGraphicsContext *context = - new wxMacCoreGraphicsContext( this, cgctx, (wxDouble) w, (wxDouble) h ); - context->EnableOffset(dc.GetContentScaleFactor() < 2); - return context; - } - return NULL; + // having a cgctx being NULL is fine (will be created on demand) + // this is the case for all wxWindowDCs except wxPaintDC + CGContextRef cgctx = (CGContextRef)(win->MacGetCGContextRef()); + wxMacCoreGraphicsContext *context = + new wxMacCoreGraphicsContext( this, cgctx, sz.x, sz.y, win ); + context->EnableOffset(dc.GetContentScaleFactor() < 2); + return context; } wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC& dc ) From d5c43831b523c889e565495682b658715017a77b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Nov 2018 03:19:27 +0100 Subject: [PATCH 035/140] Really implement wxGraphicsContext::GetDPI() Return the DPI of the associated window, if any, instead of always returning hard-coded 72*72. --- docs/changes.txt | 2 +- src/common/graphcmn.cpp | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index d59874488b..68034a6744 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -128,7 +128,7 @@ All (GUI): - Add wxGrid::SetCornerLabelValue() (Pavel Kalugin). - Add strikethrough support for fonts defined in XRC. - Add wxDisplay::GetPPI(). -- Add wxGraphicsContext::GetWindow(). +- Add wxGraphicsContext::GetWindow() and implement wxGraphicsContext::GetDPI(). wxGTK: diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 006db0586e..1f4f74cc7c 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -31,6 +31,8 @@ #include "wx/log.h" #endif +#include "wx/display.h" + #ifdef __WXMSW__ #include "wx/msw/enhmeta.h" #endif @@ -620,8 +622,19 @@ wxDouble wxGraphicsContext::GetAlpha() const void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) { - *dpiX = 72.0; - *dpiY = 72.0; + if ( m_window ) + { + const wxSize ppi = wxDisplay(m_window).GetPPI(); + *dpiX = ppi.x; + *dpiY = ppi.y; + } + else + { + // Use some standard DPI value, it doesn't make much sense for the + // contexts not using any pixels anyhow. + *dpiX = 72.0; + *dpiY = 72.0; + } } // sets the pen From bfe11f233f7990ce8447b071a3067638100196ea Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Nov 2018 03:20:24 +0100 Subject: [PATCH 036/140] Really implement wxGCDC::GetPPI() Return the DPI of the associated window, if any, instead of the hard-coded 72*72. --- src/common/dcgraph.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index d70113dfcc..292d058220 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -418,6 +418,15 @@ void wxGCDCImpl::SetTextBackground( const wxColour &col ) wxSize wxGCDCImpl::GetPPI() const { + if ( m_graphicContext ) + { + wxDouble x, y; + m_graphicContext->GetDPI(&x, &y); + return wxSize(wxRound(x), wxRound(y)); + } + + // This is the same value that wxGraphicsContext::GetDPI() returns by + // default. return wxSize(72, 72); } From 767639276f45c3c9e68b18b2b50278394c27ae94 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Nov 2018 03:57:35 +0100 Subject: [PATCH 037/140] Disable failing wxDataViewCtrl::IsExpanded() test under Mac For some unfathomable reason IsExpanded() returns wrong value for one of the items. This should be fixed, but for now just leave a warning in the test but don't fail it. Also document this bug to at least spare people some surprises. --- interface/wx/dataview.h | 3 +++ tests/controls/dataviewctrltest.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 06a662722d..00a8069f06 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -1558,6 +1558,9 @@ public: /** Return @true if the item is expanded. + + @note When using the native macOS version this method has a bug which + may result in returning @true even for items without children. */ virtual bool IsExpanded(const wxDataViewItem& item) const; diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index 0f99eecfbe..83e712a8f3 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -195,7 +195,13 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, { CHECK( m_dvc->IsExpanded(m_root) ); CHECK( !m_dvc->IsExpanded(m_child1) ); + // No idea why, but the native NSOutlineView isItemExpanded: method returns + // true for this item for some reason. +#ifdef __WXOSX__ + WARN("Disabled under MacOS: IsExpanded() returns true for grand child"); +#else CHECK( !m_dvc->IsExpanded(m_grandchild) ); +#endif CHECK( !m_dvc->IsExpanded(m_child2) ); } From caa270a1af94cd4576afbd049dd2060ba7827d10 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 6 Nov 2018 04:17:27 +0100 Subject: [PATCH 038/140] Bring Mac wxDataViewCtrl::GetItemRect() in sync with other ports Return empty rectangle if the item is not currently visible, for whatever reason, and use physical coordinates for the rectangle origin. This makes the unit test for GetItemRect() pass under macOS too. --- src/osx/cocoa/dataview.mm | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index d7f6fc362b..ce7d333e0d 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -2295,8 +2295,33 @@ wxDataViewItem wxCocoaDataViewControl::GetTopItem() const wxRect wxCocoaDataViewControl::GetRectangle(const wxDataViewItem& item, const wxDataViewColumn *columnPtr) { - return wxFromNSRect([m_osxView superview],[m_OutlineView frameOfCellAtColumn:GetColumnPosition(columnPtr) + NSView* const parent = [m_osxView superview]; + + wxRect r = wxFromNSRect(parent, [m_OutlineView frameOfCellAtColumn:GetColumnPosition(columnPtr) row:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]]]); + + // For hidden items, i.e. items not shown because their parent is + // collapsed, the native method returns rectangles with negative width, but + // we're supposed to just return an empty rectangle in this case. To be on + // the safe side, also check for the height as well, even if it seems to be + // always 0 in this case. + if ( r.width < 0 || r.height < 0 ) + return wxRect(); + + // Also adjust the vertical coordinates to use physical window coordinates + // instead of the logical ones returned by frameOfCellAtColumn:row: + NSScrollView* const scrollView = [m_OutlineView enclosingScrollView]; + const wxRect + visible = wxFromNSRect(parent, scrollView.contentView.visibleRect); + + // We are also supposed to return empty rectangle if the item is not + // visible because it is scrolled out of view. + if ( r.GetBottom() < visible.GetTop() || r.GetTop() > visible.GetBottom() ) + return wxRect(); + + r.y -= visible.y; + + return r; } bool wxCocoaDataViewControl::IsExpanded(const wxDataViewItem& item) const From 9e378480c2b2ccdf5f0da6e11c592bb02d4255fd Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 7 Nov 2018 22:12:55 +0100 Subject: [PATCH 039/140] Iterate over all characters of a wxString with iterator --- src/propgrid/propgridiface.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index d5083ecac5..2985d67f75 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -896,15 +896,16 @@ wxPGVIterator wxPropertyGridInterface::GetVIterator( int flags ) const static wxString EscapeDelimiters(const wxString& s) { wxString result; - result.Alloc(s.length()); - const wxChar* ch = s.c_str(); - while (*ch) + result.reserve(s.length()); + + for (wxString::const_iterator it = s.begin(); it != s.end(); ++it) { - if (*ch == wxT(';') || *ch == wxT('|') || *ch == wxT(',')) - result += wxT('\\'); - result += *ch; - ++ch; + wxStringCharType ch = *it; + if ( ch == wxS(';') || ch == wxS('|') || ch == wxS(',') ) + result += wxS('\\'); + result += ch; } + return result; } From bf3cfe16d4df3555f4c322ec8e2d8772b8843ddd Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 7 Nov 2018 22:16:43 +0100 Subject: [PATCH 040/140] Remove irrelevant TODO note from documentation Function is marked as deprecated so TODO note is no longer relevant. --- interface/wx/bitmap.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/wx/bitmap.h b/interface/wx/bitmap.h index 9f0405e5b5..c20aa7725e 100644 --- a/interface/wx/bitmap.h +++ b/interface/wx/bitmap.h @@ -712,9 +712,6 @@ public: Sets the depth member (does not affect the bitmap data). - @todo since these functions do not affect the bitmap data, - why they exist?? - @param depth Bitmap depth. From e484a2db1926374311ec4327605e8935d04ac873 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 8 Nov 2018 15:04:42 +0100 Subject: [PATCH 041/140] force subview refresh on macOS 10.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit even on dark mode not all NSViews have their own layer, therefore don’t take that as a condition, because a child of such a view still might be layer-backed and need an explicit redraw. Avoid spurious redraws for not visible windows (especiall important for not-yet fully constructed views or views during destruction) --- src/osx/cocoa/window.mm | 13 +++++++++---- src/osx/window_osx.cpp | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 3695a1b185..45cfdd7c37 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2575,8 +2575,11 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible ) [m_osxView setHidden:(visible ? NO:YES)]; // trigger redraw upon shown for layer-backed views - if( m_osxView.layer && !m_osxView.isHiddenOrHasHiddenAncestor ) - SetNeedsDisplay(NULL); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) ) + if( !m_osxView.isHiddenOrHasHiddenAncestor ) + SetNeedsDisplay(NULL); +#endif } double wxWidgetCocoaImpl::GetContentScaleFactor() const @@ -3032,7 +3035,7 @@ static void SetSubviewsNeedDisplay( NSView *view ) { for ( NSView *sub in view.subviews ) { - if ( sub.isHidden || !sub.layer ) + if ( sub.isHidden ) continue; [sub setNeedsDisplay:YES]; @@ -3050,8 +3053,10 @@ void wxWidgetCocoaImpl::SetNeedsDisplay( const wxRect* where ) // Layer-backed views (which are all in Mojave's Dark Mode) may not have // their children implicitly redrawn with the parent. For compatibility, // do it manually here: - if ( m_osxView.layer ) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) ) SetSubviewsNeedDisplay(m_osxView); +#endif } bool wxWidgetCocoaImpl::GetNeedsDisplay() const diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index a8242fc83c..be965a4890 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1919,6 +1919,8 @@ void wxWindowMac::MacUpdateClippedRects() const bool wxWindowMac::MacDoRedraw( long time ) { bool handled = false ; + if ( !IsShownOnScreen() ) + return handled; wxRegion formerUpdateRgn = m_updateRegion; wxRegion clientUpdateRgn = formerUpdateRgn; From cce9ef9d5340e009a0da6580bb134cd1a2859af7 Mon Sep 17 00:00:00 2001 From: VZ Date: Fri, 9 Nov 2018 17:52:58 +0100 Subject: [PATCH 042/140] Fix compatibility breakage with wxMask::Create() in wxOSX (#1019) Defining a Mac-specific Create(wxMemoryBuffer) overload hid the other Create() overloads, which are actually part of the public API, so they couldn't be used any longer since the changes of e7d21f6638a6d5f715bea5dcef461f9d19e4d979 Fix this by renaming this Create() to OSXCreate(), to avoid hiding the base class methods. Also remove Mac-specific ctor taking wxMemoryBuffer, this is confusing and can be avoided by just calling OSXCreate() directly in the only place where it is used. --- include/wx/osx/bitmap.h | 8 +++----- src/osx/core/bitmap.cpp | 18 ++++++------------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/include/wx/osx/bitmap.h b/include/wx/osx/bitmap.h index 4252da9f9c..65255198e9 100644 --- a/include/wx/osx/bitmap.h +++ b/include/wx/osx/bitmap.h @@ -47,13 +47,8 @@ public: // Construct a mask from a mono bitmap (black meaning show pixels, white meaning transparent) wxMask(const wxBitmap& bitmap); - // implementation helper only : construct a mask from a 32 bit memory buffer - wxMask(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ; - virtual ~wxMask(); - bool Create(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ; - wxBitmap GetBitmap() const; // Implementation below @@ -71,6 +66,9 @@ public: WXHBITMAP GetHBITMAP() const ; + // implementation helper only : construct a mask from a 32 bit memory buffer + bool OSXCreate(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ; + protected: // this function is called from Create() to free the existing mask data virtual void FreeData() wxOVERRIDE; diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 5170f3f53b..fcfb40816b 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1062,7 +1062,9 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const maskbuf.UngetWriteBuf( maskbufsize ) ; } - ret.SetMask( new wxMask( maskbuf , destwidth , destheight , rowBytes ) ) ; + wxMask* const mask = new wxMask(); + mask->OSXCreate( maskbuf , destwidth , destheight , rowBytes ); + ret.SetMask(mask) ; } else if ( HasAlpha() ) ret.UseAlpha() ; @@ -1505,22 +1507,14 @@ wxMask::wxMask(const wxMask &tocopy) : wxMaskBase() wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour ) { Init() ; - wxMaskBase::Create( bitmap, colour ); + Create( bitmap, colour ); } // Construct a mask from a mono bitmap (copies the bitmap). wxMask::wxMask( const wxBitmap& bitmap ) { Init() ; - wxMaskBase::Create( bitmap ); -} - -// Construct a mask from a mono bitmap (copies the bitmap). - -wxMask::wxMask( const wxMemoryBuffer& data, int width , int height , int bytesPerRow ) -{ - Init() ; - Create( data, width , height , bytesPerRow ); + Create( bitmap ); } wxMask::~wxMask() @@ -1591,7 +1585,7 @@ void wxMask::RealizeNative() // Create a mask from a mono bitmap (copies the bitmap). -bool wxMask::Create(const wxMemoryBuffer& data,int width , int height , int bytesPerRow) +bool wxMask::OSXCreate(const wxMemoryBuffer& data,int width , int height , int bytesPerRow) { wxASSERT( data.GetDataLen() == (size_t)(height * bytesPerRow) ) ; From 664b8c153f6c4297b5acbd48c299637f417f3c4a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 3 Nov 2018 23:14:56 +0100 Subject: [PATCH 043/140] Don't export sorted dynamic arrays from the shared library This shouldn't be necessary and doing it seems to result in duplicate symbol errors when using MSVC under some not completely elucidated circumstances. See https://github.com/utelle/wxpdfdoc/pull/48 Closes https://github.com/wxWidgets/wxWidgets/pull/1013 --- include/wx/dynarray.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 84a65cbce6..a8684e7999 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -215,9 +215,11 @@ public: // cannot handle types with size greater than pointer because of sorting // ---------------------------------------------------------------------------- -#define _WX_DEFINE_SORTED_TYPEARRAY_2(T, name, base, defcomp, classexp) \ +// Note that "classdecl" here is intentionally not used because this class has +// only inline methods and so never needs to be exported from a DLL. +#define _WX_DEFINE_SORTED_TYPEARRAY_2(T, name, base, defcomp, classdecl) \ typedef wxBaseSortedArray wxBaseSortedArrayFor##name; \ - classexp name : public wxBaseSortedArrayFor##name \ + class name : public wxBaseSortedArrayFor##name \ { \ public: \ name(wxBaseSortedArrayFor##name::SCMPFUNC fn defcomp) \ From 41898c8dc406aef32b959d27eac70524b76b9b9a Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 14:49:52 +0100 Subject: [PATCH 044/140] Compilation fix for wxUSE_INTL=0 build --- src/generic/timectrlg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generic/timectrlg.cpp b/src/generic/timectrlg.cpp index 4037d6f56d..efa0af028d 100644 --- a/src/generic/timectrlg.cpp +++ b/src/generic/timectrlg.cpp @@ -86,7 +86,7 @@ public: // nice to add support to "%k" and "%l" (hours with leading blanks // instead of zeros) too as this is the most common unsupported case in // practice. -#if wxUSE_XLOCALE +#if wxUSE_INTL m_useAMPM = wxLocale::GetInfo(wxLOCALE_TIME_FMT).Contains("%p"); #else m_useAMPM = false; From f3b6e6d3b58810d7da2121976e8ffa522b7db5ec Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 14:59:27 +0100 Subject: [PATCH 045/140] Fix date format specification in wxDatePickerCtrlGeneric with wxUSE_INTL=0 Conversion specification for preferred date representation is "%x", not "x". --- src/generic/datectlg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 5ddadc3933..7a405e2c9b 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -252,7 +252,7 @@ private: return fmt; #else // !wxUSE_INTL - return wxT("x"); + return wxS("%x"); #endif // wxUSE_INTL/!wxUSE_INTL } From 7911d50335b8c2f2928e3afc498d8d6776deed4b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 20:39:56 +0100 Subject: [PATCH 046/140] Use locale-specific date format There is no need to construct format string manually. --- src/propgrid/advprops.cpp | 50 ++++++++------------------------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index b18e0ad834..9ff59a10cf 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -2316,8 +2316,6 @@ wxString wxDateProperty::ValueToString( wxVariant& value, format = m_format.c_str(); // Determine default from locale - // NB: This is really simple stuff, but can't figure anything - // better without proper support in wxLocale if ( !format ) format = ms_defaultDateFormat.c_str(); @@ -2326,46 +2324,18 @@ wxString wxDateProperty::ValueToString( wxVariant& value, wxString wxDateProperty::DetermineDefaultDateFormat( bool showCentury ) { - // This code is basically copied from datectlg.cpp's SetFormat - // - wxString format; - - wxDateTime dt; - dt.ParseFormat(wxS("2003-10-13"), wxS("%Y-%m-%d")); - wxString str(dt.Format(wxS("%x"))); - - const wxChar *p = str.c_str(); - while ( *p ) - { - int n=wxAtoi(p); - if (n == dt.GetDay()) - { - format.Append(wxS("%d")); - p += 2; - } - else if (n == (int)dt.GetMonth()+1) - { - format.Append(wxS("%m")); - p += 2; - } - else if (n == dt.GetYear()) - { - format.Append(wxS("%Y")); - p += 4; - } - else if (n == (dt.GetYear() % 100)) - { - if (showCentury) - format.Append(wxS("%Y")); - else - format.Append(wxS("%y")); - p += 2; - } - else - format.Append(*p++); - } + // This code is based on datectlg.cpp's GetLocaleDateFormat() +#if wxUSE_INTL + wxString format = wxLocale::GetOSInfo(wxLOCALE_SHORT_DATE_FMT); + if ( showCentury ) + format.Replace(wxS("%y"), wxS("%Y")); + else + format.Replace(wxS("%Y"), wxS("%y")); return format; +#else + return wxS("%x"); +#endif // wxUSE_INTL/!wxUSE_INTL } bool wxDateProperty::DoSetAttribute( const wxString& name, wxVariant& value ) From c606a7fc9fac100dbf795fa66c83c5368c9c5d00 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 20:40:59 +0100 Subject: [PATCH 047/140] Store format as wxString Using wxString here is simpler and not misleading. --- src/propgrid/advprops.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 9ff59a10cf..f65cc49918 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -2294,8 +2294,6 @@ bool wxDateProperty::StringToValue( wxVariant& variant, const wxString& text, wxString wxDateProperty::ValueToString( wxVariant& value, int argFlags ) const { - const wxChar* format = (const wxChar*) NULL; - wxDateTime dateTime = value.GetDateTime(); if ( !dateTime.IsValid() ) @@ -2311,13 +2309,14 @@ wxString wxDateProperty::ValueToString( wxVariant& value, ms_defaultDateFormat = DetermineDefaultDateFormat( showCentury ); } + wxString format; if ( !m_format.empty() && !(argFlags & wxPG_FULL_VALUE) ) - format = m_format.c_str(); + format = m_format; // Determine default from locale - if ( !format ) - format = ms_defaultDateFormat.c_str(); + if ( format.empty() ) + format = ms_defaultDateFormat; return dateTime.Format(format); } From 322d6874c332f04e5bb0b415a7f2912f6ac811aa Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 20:43:57 +0100 Subject: [PATCH 048/140] Use wxVector<> instead of wxArrayPGProperty --- include/wx/propgrid/property.h | 2 +- src/propgrid/property.cpp | 64 ++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index d93595cf0e..77d8c4b09a 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -2019,7 +2019,7 @@ protected: wxVariant m_value; wxPGAttributeStorage m_attributes; - wxArrayPGProperty m_children; + wxVector m_children; // Extended cell information wxVector m_cells; diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index a09beb72e1..0aa8255102 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -104,6 +104,48 @@ static void wxPGDrawFocusRect(wxWindow *win, wxDC& dc, #endif // wxPG_USE_NATIVE_FOCUS_RECT_RENDERER/!wxPG_USE_NATIVE_FOCUS_RECT_RENDERER } +// Utility to determine the index of the item in the vector. +template +static int wxPGItemIndexInVector(const wxVector& vector, const T& item) +{ +#if wxUSE_STL + typename wxVector::const_iterator it = std::find(vector.begin(), vector.end(), item); + if ( it != vector.end() ) + return (int)(it - vector.begin()); + + return wxNOT_FOUND; +#else + for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + return (int)(it - vector.begin()); + } + return wxNOT_FOUND; +#endif // wxUSE_STL/!wxUSE_STL +} + +// Utility to remove given item from the vector. +template +static void wxPGRemoveItemFromVector(wxVector& vector, const T& item) +{ +#if wxUSE_STL + typename wxVector::iterator it = std::find(vector.begin(), vector.end(), item); + if ( it != vector.end() ) + { + vector.erase(it); + } +#else + for (typename wxVector::iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + { + vector.erase(it); + return; + } + } +#endif // wxUSE_STL/!wxUSE_STL +} + // ----------------------------------------------------------------------- // wxPGCellRenderer // ----------------------------------------------------------------------- @@ -781,7 +823,7 @@ wxPropertyGrid* wxPGProperty::GetGrid() const int wxPGProperty::Index( const wxPGProperty* p ) const { - return m_children.Index(const_cast(p)); + return wxPGItemIndexInVector(m_children, const_cast(p)); } bool wxPGProperty::ValidateValue( wxVariant& WXUNUSED(value), wxPGValidationInfo& WXUNUSED(validationInfo) ) const @@ -2416,17 +2458,7 @@ wxPGProperty* wxPGProperty::InsertChild( int index, void wxPGProperty::RemoveChild( wxPGProperty* p ) { - wxArrayPGProperty::iterator it; - wxArrayPGProperty& children = m_children; - - for ( it=children.begin(); it != children.end(); ++it ) - { - if ( *it == p ) - { - children.erase(it); - break; - } - } + wxPGRemoveItemFromVector(m_children, p); } void wxPGProperty::RemoveChild(unsigned int index) @@ -2436,12 +2468,8 @@ void wxPGProperty::RemoveChild(unsigned int index) void wxPGProperty::SortChildren(int (*fCmp)(wxPGProperty**, wxPGProperty**)) { - m_children.Sort(fCmp); - -#if 0 - // For wxVector w/ wxUSE_STL=1, you would use code like this instead: - std::sort(m_children.begin(), m_children.end(), fCmp); -#endif + wxArray_SortFunction sf(fCmp); + std::sort(m_children.begin(), m_children.end(), sf); } void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const From e2115d0d6fae0a8f69a2fab334164e5e4661934b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 20:44:53 +0100 Subject: [PATCH 049/140] Remove unneeded calls to c_str() --- include/wx/propgrid/propgriddefs.h | 4 ++-- src/propgrid/advprops.cpp | 2 +- src/propgrid/property.cpp | 20 ++++++++++---------- src/propgrid/propgrid.cpp | 20 ++++++++++---------- src/propgrid/propgridiface.cpp | 4 ++-- src/propgrid/propgridpagestate.cpp | 2 +- src/propgrid/props.cpp | 20 ++++++++++---------- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/wx/propgrid/propgriddefs.h b/include/wx/propgrid/propgriddefs.h index 5dcc6cd973..868f355357 100644 --- a/include/wx/propgrid/propgriddefs.h +++ b/include/wx/propgrid/propgriddefs.h @@ -547,7 +547,7 @@ expdecl classname& classname##RefFromVariant( wxVariant& variant ) \ wxString::Format(wxS("Variant type should have been '%s'") \ wxS("instead of '%s'"), \ wxS(#classname), \ - variant.GetType().c_str())); \ + variant.GetType())); \ classname##VariantData *data = \ (classname##VariantData*) variant.GetData(); \ return data->GetValue();\ @@ -558,7 +558,7 @@ expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \ wxString::Format(wxS("Variant type should have been '%s'") \ wxS("instead of '%s'"), \ wxS(#classname), \ - variant.GetType().c_str())); \ + variant.GetType())); \ classname##VariantData *data = \ (classname##VariantData*) variant.GetData(); \ return data->GetValue();\ diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index f65cc49918..5a9af11668 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1085,7 +1085,7 @@ int wxSystemColourProperty::ColToInd( const wxColour& colour ) const if ( colour == GetColour(ind) ) { /*wxLogDebug(wxS("%s(%s): Index %i for ( getcolour(%i,%i,%i), colour(%i,%i,%i))"), - GetClassName(),GetLabel().c_str(), + GetClassName(),GetLabel(), (int)i,(int)GetColour(ind).Red(),(int)GetColour(ind).Green(),(int)GetColour(ind).Blue(), (int)colour.Red(),(int)colour.Green(),(int)colour.Blue());*/ return ind; diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 0aa8255102..5f46ee783f 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -337,7 +337,7 @@ bool wxPGDefaultRenderer::Render( wxDC& dc, const wxRect& rect, { wxString unitsString = property->GetAttribute(wxPG_ATTR_UNITS, wxEmptyString); if ( !unitsString.empty() ) - text = wxString::Format(wxS("%s %s"), text.c_str(), unitsString.c_str() ); + text = wxString::Format(wxS("%s %s"), text, unitsString ); } } @@ -919,7 +919,7 @@ void wxPGProperty::GetDisplayInfo( unsigned int column, wxASSERT_MSG( cell.GetData(), wxString::Format(wxS("Invalid cell for property %s"), - GetName().c_str()) ); + GetName()) ); // We need to return customized cell object. if (pCell) @@ -1470,7 +1470,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) wxVariant newValue; AdaptListToValue(value, &newValue); value = newValue; - //wxLogDebug(wxS(">> %s.SetValue() adapted list value to type '%s'"),GetName().c_str(),value.GetType().c_str()); + //wxLogDebug(wxS(">> %s.SetValue() adapted list value to type '%s'"),GetName(),value.GetType()); } if ( HasFlag( wxPG_PROP_AGGREGATE) ) @@ -1486,7 +1486,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) wxVariantList::iterator node; unsigned int i = 0; - //wxLogDebug(wxS(">> %s.SetValue() pList parsing"),GetName().c_str()); + //wxLogDebug(wxS(">> %s.SetValue() pList parsing"),GetName()); // Children in list can be in any order, but we will give hint to // GetPropertyByNameWH(). This optimizes for full list parsing. @@ -1496,7 +1496,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) wxPGProperty* child = GetPropertyByNameWH(childValue.GetName(), i); if ( child ) { - //wxLogDebug(wxS("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName().c_str(),childValue.GetType().c_str()); + //wxLogDebug(wxS("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName(),childValue.GetType()); if ( childValue.IsType(wxPG_VARIANT_TYPE_LIST) ) { if ( child->HasFlag(wxPG_PROP_AGGREGATE) && !(flags & wxPG_SETVAL_AGGREGATED) ) @@ -1966,7 +1966,7 @@ double wxPGProperty::GetAttributeAsDouble( const wxString& name, double defVal ) wxVariant wxPGProperty::GetAttributesAsList() const { wxVariantList tempList; - wxVariant v( tempList, wxString::Format(wxS("@%s@attr"),m_name.c_str()) ); + wxVariant v( tempList, wxString::Format(wxS("@%s@attr"),m_name) ); wxPGAttributeStorage::const_iterator it = m_attributes.StartIteration(); wxVariant variant; @@ -2496,7 +2496,7 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const unsigned int n = 0; wxVariant childValue = list[n]; - //wxLogDebug(wxS(">> %s.AdaptListToValue()"),GetBaseName().c_str()); + //wxLogDebug(wxS(">> %s.AdaptListToValue()"),GetBaseName()); for ( unsigned int i = 0; i < GetChildCount(); i++ ) { @@ -2504,7 +2504,7 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const if ( childValue.GetName() == child->GetBaseName() ) { - //wxLogDebug(wxS(" %s(n=%i), %s"),childValue.GetName().c_str(),n,childValue.GetType().c_str()); + //wxLogDebug(wxS(" %s(n=%i), %s"),childValue.GetName(),n,childValue.GetType()); if ( childValue.IsType(wxPG_VARIANT_TYPE_LIST) ) { @@ -2678,11 +2678,11 @@ wxPGProperty* wxPGProperty::GetItemAtY( unsigned int y, /* if ( current ) { - wxLogDebug(wxS("%s::GetItemAtY(%i) -> %s"),this->GetLabel().c_str(),y,current->GetLabel().c_str()); + wxLogDebug(wxS("%s::GetItemAtY(%i) -> %s"),this->GetLabel(),y,current->GetLabel()); } else { - wxLogDebug(wxS("%s::GetItemAtY(%i) -> NULL"),this->GetLabel().c_str(),y); + wxLogDebug(wxS("%s::GetItemAtY(%i) -> NULL"),this->GetLabel(),y); } */ diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 9ea2aeba5f..b910fe5d5e 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -2095,8 +2095,8 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, /* wxLogDebug(wxS(" -> DoDrawItems(\"%s\" -> \"%s\"") wxS(" %i -> %i height=%i (ch=%i), itemsRect = 0x%lX %i,%i %ix%i)"), - firstItem->GetLabel().c_str(), - lastItem->GetLabel().c_str(), + firstItem->GetLabel(), + lastItem->GetLabel(), firstItemTopY, lastItemBottomY, (int)(lastItemBottomY - firstItemTopY), (int)m_height, @@ -4021,8 +4021,8 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) /* if (p) { - wxLogDebug(wxS("SelectProperty( %s (%s[%i]) )"),p->GetLabel().c_str(), - p->m_parent->GetLabel().c_str(),p->GetIndexInParent()); + wxLogDebug(wxS("SelectProperty( %s (%s[%i]) )"),p->GetLabel(), + p->m_parent->GetLabel(),p->GetIndexInParent()); } else { @@ -6438,13 +6438,13 @@ wxPGProperty* wxPropertyGridPopulator::Add( const wxString& propClass, if ( parent->HasFlag(wxPG_PROP_AGGREGATE) ) { - ProcessError(wxString::Format(wxS("new children cannot be added to '%s'"),parent->GetName().c_str())); + ProcessError(wxString::Format(wxS("new children cannot be added to '%s'"),parent->GetName())); return NULL; } if ( !classInfo || !classInfo->IsKindOf(wxCLASSINFO(wxPGProperty)) ) { - ProcessError(wxString::Format(wxS("'%s' is not valid property class"),propClass.c_str())); + ProcessError(wxString::Format(wxS("'%s' is not valid property class"),propClass)); return NULL; } @@ -6487,7 +6487,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString wxString ids = choicesString.substr(1); wxPGHashMapS2P::iterator it = m_dictIdChoices.find(ids); if ( it == m_dictIdChoices.end() ) - ProcessError(wxString::Format(wxS("No choices defined for id '%s'"),ids.c_str())); + ProcessError(wxString::Format(wxS("No choices defined for id '%s'"),ids)); else choices.AssignData((wxPGChoicesData*)it->second); } @@ -6528,7 +6528,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString choices.Add(label, l); } labelValid = false; - //wxLogDebug(wxS("%s, %s"),label.c_str(),value.c_str()); + //wxLogDebug(wxS("%s, %s"),label,value); value.clear(); label.clear(); state = 1; @@ -6645,7 +6645,7 @@ bool wxPropertyGridPopulator::AddAttribute( const wxString& name, } else { - ProcessError(wxString::Format(wxS("Invalid attribute type '%s'"),type.c_str())); + ProcessError(wxString::Format(wxS("Invalid attribute type '%s'"),type)); return false; } } @@ -6659,7 +6659,7 @@ bool wxPropertyGridPopulator::AddAttribute( const wxString& name, void wxPropertyGridPopulator::ProcessError( const wxString& msg ) { - wxLogError(_("Error in resource: %s"),msg.c_str()); + wxLogError(_("Error in resource: %s"),msg); } // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index 2985d67f75..307753986e 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -399,7 +399,7 @@ void wxPGTypeOperationFailed( const wxPGProperty* p, { wxASSERT( p != NULL ); wxLogError( _("Type operation \"%s\" failed: Property labeled \"%s\" is of type \"%s\", NOT \"%s\"."), - op.c_str(), p->GetLabel().c_str(), p->GetValue().GetType().c_str(), typestr.c_str() ); + op, p->GetLabel(), p->GetValue().GetType(), typestr ); } // ----------------------------------------------------------------------- @@ -434,7 +434,7 @@ void wxPropertyGridInterface::SetValidationFailureBehavior( int vfbFlags ) wxPGProperty* wxPropertyGridInterface::GetPropertyByNameA( const wxString& name ) const { wxPGProperty* p = GetPropertyByName(name); - wxASSERT_MSG(p,wxString::Format(wxS("no property with name '%s'"),name.c_str())); + wxASSERT_MSG(p,wxString::Format(wxS("no property with name '%s'"),name)); return p; } diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index be18422604..e87a34a115 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -1599,7 +1599,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx wxStrcmp(current->GetType(), p->GetValue().GetType()) == 0, wxString::Format( wxS("setting value of property \"%s\" from variant"), - p->GetName().c_str()) + p->GetName()) ); p->SetValue(*current); diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 4fbd16c3d1..cdc0557851 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -385,14 +385,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !maxOk ) msg = wxString::Format( _("Value must be %s or higher."), - smin.c_str()); + smin); else { wxVariant vmax = WXVARIANT(max); wxString smax = property->ValueToString(vmax); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -416,14 +416,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !minOk ) msg = wxString::Format( _("Value must be %s or less."), - smax.c_str()); + smax); else { wxVariant vmin = WXVARIANT(min); wxString smin = property->ValueToString(vmin); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -499,14 +499,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !maxOk ) msg = wxString::Format( _("Value must be %s or higher."), - smin.c_str()); + smin); else { wxVariant vmax = WXVARIANT(max); wxString smax = property->ValueToString(vmax); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -530,14 +530,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !minOk ) msg = wxString::Format( _("Value must be %s or less."), - smax.c_str()); + smax); else { wxVariant vmin = WXVARIANT(min); wxString smin = property->ValueToString(vmin); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -923,7 +923,7 @@ const wxString& wxPropertyGrid::DoubleToString(wxString& target, *precTemplate << wxS('f'); } - target.Printf( precTemplate->c_str(), value ); + target.Printf( *precTemplate, value ); } else { @@ -1131,7 +1131,7 @@ wxString wxBoolProperty::ValueToString( wxVariant& value, else notFmt = wxS("Not %s"); - return wxString::Format(notFmt.c_str(), m_label.c_str()); + return wxString::Format(notFmt, m_label); } } From 43f7e35c52cfc0b50db1313ced9f1b7d7e71ae7a Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 20:56:24 +0100 Subject: [PATCH 050/140] Explicitly return Boolean value as declared --- include/wx/generic/spinctlg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wx/generic/spinctlg.h b/include/wx/generic/spinctlg.h index 7f5b5de50a..c3d2e9eef5 100644 --- a/include/wx/generic/spinctlg.h +++ b/include/wx/generic/spinctlg.h @@ -403,7 +403,7 @@ public: // We don't implement bases support for floating point numbers, this is not // very useful in practice. virtual int GetBase() const wxOVERRIDE { return 10; } - virtual bool SetBase(int WXUNUSED(base)) wxOVERRIDE { return 0; } + virtual bool SetBase(int WXUNUSED(base)) wxOVERRIDE { return false; } protected: virtual void DoSendEvent() wxOVERRIDE; From c86f795914bd221738bba439c8fe082a8b74ef2e Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 10 Nov 2018 21:20:06 +0100 Subject: [PATCH 051/140] Move shared wxVector utilities to one place --- include/wx/propgrid/propgriddefs.h | 61 ++++++++++++++++++++++++++++++ src/propgrid/property.cpp | 42 -------------------- src/propgrid/propgrid.cpp | 16 -------- src/propgrid/propgridpagestate.cpp | 38 ------------------- 4 files changed, 61 insertions(+), 96 deletions(-) diff --git a/include/wx/propgrid/propgriddefs.h b/include/wx/propgrid/propgriddefs.h index 868f355357..6eebf00177 100644 --- a/include/wx/propgrid/propgriddefs.h +++ b/include/wx/propgrid/propgriddefs.h @@ -699,6 +699,67 @@ protected: #define WX_PG_TOKENIZER2_END() \ } +// ----------------------------------------------------------------------- +// wxVector utilities + +// Utility to check if specific item is in a vector. +template +inline bool wxPGItemExistsInVector(const wxVector& vector, const T& item) +{ +#if wxUSE_STL + return std::find(vector.begin(), vector.end(), item) != vector.end(); +#else + for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + return true; + } + return false; +#endif // wxUSE_STL/!wxUSE_STL +} + +// Utility to determine the index of the item in the vector. +template +inline int wxPGItemIndexInVector(const wxVector& vector, const T& item) +{ +#if wxUSE_STL + typename wxVector::const_iterator it = std::find(vector.begin(), vector.end(), item); + if ( it != vector.end() ) + return (int)(it - vector.begin()); + + return wxNOT_FOUND; +#else + for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + return (int)(it - vector.begin()); + } + return wxNOT_FOUND; +#endif // wxUSE_STL/!wxUSE_STL +} + +// Utility to remove given item from the vector. +template +inline void wxPGRemoveItemFromVector(wxVector& vector, const T& item) +{ +#if wxUSE_STL + typename wxVector::iterator it = std::find(vector.begin(), vector.end(), item); + if ( it != vector.end() ) + { + vector.erase(it); + } +#else + for (typename wxVector::iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + { + vector.erase(it); + return; + } + } +#endif // wxUSE_STL/!wxUSE_STL +} + // ----------------------------------------------------------------------- #endif // wxUSE_PROPGRID diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 5f46ee783f..9716d3676d 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -104,48 +104,6 @@ static void wxPGDrawFocusRect(wxWindow *win, wxDC& dc, #endif // wxPG_USE_NATIVE_FOCUS_RECT_RENDERER/!wxPG_USE_NATIVE_FOCUS_RECT_RENDERER } -// Utility to determine the index of the item in the vector. -template -static int wxPGItemIndexInVector(const wxVector& vector, const T& item) -{ -#if wxUSE_STL - typename wxVector::const_iterator it = std::find(vector.begin(), vector.end(), item); - if ( it != vector.end() ) - return (int)(it - vector.begin()); - - return wxNOT_FOUND; -#else - for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - return (int)(it - vector.begin()); - } - return wxNOT_FOUND; -#endif // wxUSE_STL/!wxUSE_STL -} - -// Utility to remove given item from the vector. -template -static void wxPGRemoveItemFromVector(wxVector& vector, const T& item) -{ -#if wxUSE_STL - typename wxVector::iterator it = std::find(vector.begin(), vector.end(), item); - if ( it != vector.end() ) - { - vector.erase(it); - } -#else - for (typename wxVector::iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - { - vector.erase(it); - return; - } - } -#endif // wxUSE_STL/!wxUSE_STL -} - // ----------------------------------------------------------------------- // wxPGCellRenderer // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index b910fe5d5e..e4e4639084 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -137,22 +137,6 @@ DeletedObjects gs_deletedEditorObjects; } // anonymous namespace #endif - // Utility to check if specific item is in a vector. -template -static bool wxPGItemExistsInVector(const wxVector& vector, const T& item) -{ -#if wxUSE_STL - return std::find(vector.begin(), vector.end(), item) != vector.end(); -#else - for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - return true; - } - return false; -#endif // wxUSE_STL/!wxUSE_STL -} - // ----------------------------------------------------------------------- #if wxUSE_INTL diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index e87a34a115..6d11d450a1 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -43,44 +43,6 @@ #define wxPG_DEFAULT_SPLITTERX 110 -// Utility to remove given item from the vector. -template -static void wxPGRemoveItemFromVector(wxVector& vector, const T& item) -{ -#if wxUSE_STL - typename wxVector::iterator it = std::find(vector.begin(), vector.end(), item); - if ( it != vector.end() ) - { - vector.erase(it); - } -#else - for (typename wxVector::iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - { - vector.erase(it); - return; - } - } -#endif // wxUSE_STL/!wxUSE_STL -} - -// Utility to check if specific item is in a vector. -template -static bool wxPGItemExistsInVector(const wxVector& vector, const T& item) -{ -#if wxUSE_STL - return std::find(vector.begin(), vector.end(), item) != vector.end(); -#else - for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - return true; - } - return false; -#endif // wxUSE_STL/!wxUSE_STL -} - // ----------------------------------------------------------------------- // wxPropertyGridIterator // ----------------------------------------------------------------------- From c252ececdae34cbf492e07d87cfbf2f67a8c9a5f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Nov 2018 23:29:54 +0100 Subject: [PATCH 052/140] Consistently set m_enableOffset for wxMacCoreGraphicsContext Previously it was set to true if content scale factor was less or equal to 1 in some places or if it was strictly less than 2 in some others. Fix this by adding a new helper SetEnableOffsetFromScaleFactor() function and using it everywhere to consistently only enable offset for non-high DPI displays in all cases. --- src/osx/carbon/graphics.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index c8f96aa43f..c8a926ec79 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -1315,6 +1315,12 @@ public: ~wxMacCoreGraphicsContext(); + // Enable offset on non-high DPI displays, i.e. those with scale factor <= 1. + void SetEnableOffsetFromScaleFactor(double factor) + { + m_enableOffset = factor <= 1.0; + } + void Init(); virtual void StartPage( wxDouble width, wxDouble height ) wxOVERRIDE; @@ -1533,7 +1539,7 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer { Init(); - m_enableOffset = window->GetContentScaleFactor() <= 1; + SetEnableOffsetFromScaleFactor(window->GetContentScaleFactor()); wxSize sz = window->GetSize(); m_width = sz.x; m_height = sz.y; @@ -2715,7 +2721,7 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& CGContextRef cgctx = (CGContextRef)(win->MacGetCGContextRef()); wxMacCoreGraphicsContext *context = new wxMacCoreGraphicsContext( this, cgctx, sz.x, sz.y, win ); - context->EnableOffset(dc.GetContentScaleFactor() < 2); + context->SetEnableOffsetFromScaleFactor(dc.GetContentScaleFactor()); return context; } @@ -2730,7 +2736,7 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC& mem_impl->GetSize( &w, &h ); wxMacCoreGraphicsContext* context = new wxMacCoreGraphicsContext( this, (CGContextRef)(mem_impl->GetGraphicsContext()->GetNativeContext()), (wxDouble) w, (wxDouble) h ); - context->EnableOffset(dc.GetContentScaleFactor() < 2); + context->SetEnableOffsetFromScaleFactor(dc.GetContentScaleFactor()); return context; } #endif From 87195cf3ea7ca1abd1a3721b32b766fc36ee568d Mon Sep 17 00:00:00 2001 From: jbbbms Date: Sat, 10 Nov 2018 23:37:33 +0100 Subject: [PATCH 053/140] Put wxDECLARE_EVENT_TABLE at the end of wxTextCtrl declaration This fixes the access specifier effectively used for the members following these macros, as it's changed to "public" inside them, meaning that e.g. m_privateContextMenu was actually public even though it was ostensibly declared in the private section and the intention was for it to be private. Closes #16038. --- include/wx/msw/textctrl.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index 4fe3a470e6..5ef3128a7c 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -290,9 +290,6 @@ private: // false if we hit the limit set by SetMaxLength() and so didn't change it. bool AdjustSpaceLimit(); - wxDECLARE_EVENT_TABLE(); - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl); - wxMenu* m_privateContextMenu; bool m_isNativeCaretShown; @@ -301,6 +298,8 @@ private: int m_isInkEdit; #endif + wxDECLARE_EVENT_TABLE(); + wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl); }; #endif // _WX_TEXTCTRL_H_ From d27a1b27708adfdebebb1921354280ca148c88e3 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 11 Nov 2018 11:12:08 +0100 Subject: [PATCH 054/140] Create standard dialog buttons with dedicated function Use CreateStdDialogButtonSizer() function instead of constructing wxStdDialogButtonSizer manually. --- src/propgrid/props.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index cdc0557851..0d4b3ead19 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -2315,11 +2315,10 @@ bool wxLongStringProperty::DisplayEditorDialog( wxPGProperty* prop, wxPropertyGr rowsizer->Add(ed, wxSizerFlags(1).Expand().Border(wxALL, spacing)); topsizer->Add(rowsizer, wxSizerFlags(1).Expand()); - wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer(); + long btnSizerFlags = wxCANCEL; if ( !prop->HasFlag(wxPG_PROP_READONLY) ) - buttonSizer->AddButton(new wxButton(dlg, wxID_OK)); - buttonSizer->AddButton(new wxButton(dlg, wxID_CANCEL)); - buttonSizer->Realize(); + btnSizerFlags |= wxOK; + wxStdDialogButtonSizer* buttonSizer = dlg->CreateStdDialogButtonSizer(btnSizerFlags); topsizer->Add(buttonSizer, wxSizerFlags(0).Right().Border(wxBOTTOM|wxRIGHT, spacing)); dlg->SetSizer( topsizer ); @@ -2494,10 +2493,7 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent, topsizer->Add(m_elb, wxSizerFlags(1).Expand().Border(0, spacing)); // Standard dialog buttons - wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer(); - buttonSizer->AddButton(new wxButton(this, wxID_OK)); - buttonSizer->AddButton(new wxButton(this, wxID_CANCEL)); - buttonSizer->Realize(); + wxStdDialogButtonSizer* buttonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); topsizer->Add(buttonSizer, wxSizerFlags(0).Right().Border(wxALL, spacing)); m_elb->SetFocus(); From 4e2d26b22eca8ac0f90c07a9c631b8b2a9eee933 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 11 Nov 2018 11:19:29 +0100 Subject: [PATCH 055/140] Keep wxPGProperty editor focused while refreshing the property Active property's editor should remain focused after refreshing the property. --- src/propgrid/propgrid.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index e4e4639084..fc76cfb8e0 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -2590,7 +2590,11 @@ void wxPropertyGrid::RefreshProperty( wxPGProperty* p ) { // NB: We must copy the selection. wxArrayPGProperty selection = m_pState->m_selection; - DoSetSelection(selection, wxPG_SEL_FORCE); + int selFlags = wxPG_SEL_FORCE; + // We want to keep property's editor focused. + if ( IsEditorFocused() ) + selFlags |= wxPG_SEL_FOCUS; + DoSetSelection(selection, selFlags); } DrawItemAndChildren(p); From fe4f35b0a345f3f2437be84214f5f6eb96730f44 Mon Sep 17 00:00:00 2001 From: Andy Robinson Date: Sun, 11 Nov 2018 01:33:53 +0100 Subject: [PATCH 056/140] Make wxFrame::EnableFullScreenView() work under macOS 10.11+ We must explicitly turn on NSWindowCollectionBehaviorFullScreenAuxiliary flag to prevent the window from becoming shown in full screen. Closes #18168. --- docs/changes.txt | 1 + src/osx/cocoa/nonownedwnd.mm | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index f3c9b416d1..4884631dcf 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -175,6 +175,7 @@ wxOSX: - supporting native image formst like NSImage and UIImage in wxBitmap - native implementation for wxStaticBitmap for correct rendering of template images - Fill column value in wxEVT_DATAVIEW_ITEM_ACTIVATED events (Igor Korot). +- Make wxFrame::EnableFullScreenView() work under macOS 10.11+ (Andy Robinson). wxQt: diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index a1084ccc15..61ea6270a0 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -1092,10 +1092,18 @@ bool wxNonOwnedWindowCocoaImpl::EnableFullScreenView(bool enable) if (enable) { collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary; + collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; } else { + // Note that just turning "Full Screen Primary" is not enough, the + // window would still be made full screen when the green button in the + // title bar is pressed, and we need to explicitly turn on the "Full + // Screen Auxiliary" style to prevent this from happening. This works, + // at least under 10.11 and 10.14, even though it's not really clear + // from the documentation that it should. collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary; + collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary; } [m_macWindow setCollectionBehavior: collectionBehavior]; From 6e3f818da18ab27414a78c063ac8a48ef0cda6b4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 Nov 2018 01:35:37 +0100 Subject: [PATCH 057/140] Fix formatting of change log entries for consistency Capitalize the entries, keep them under 80 columns and terminate with full stop. Also fix a typo. No real changes. --- docs/changes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 4884631dcf..6f7dd41b18 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -172,8 +172,8 @@ wxOSX: - Fix dispatching pending events (and CallAfter()) in console applications. - Implement wxDataViewColumn::UnsetAsSortKey() (Daniel Kulp). -- supporting native image formst like NSImage and UIImage in wxBitmap -- native implementation for wxStaticBitmap for correct rendering of template images +- Change wxBitmap to use native image format like NSImage and UIImage. +- Implement wxStaticBitmap natively for correct rendering of template images. - Fill column value in wxEVT_DATAVIEW_ITEM_ACTIVATED events (Igor Korot). - Make wxFrame::EnableFullScreenView() work under macOS 10.11+ (Andy Robinson). From b07305234c6e58773452238f3b0dbecb3ae9365b Mon Sep 17 00:00:00 2001 From: John Gehrig Date: Thu, 11 Oct 2018 15:47:16 -0400 Subject: [PATCH 058/140] Fix dragging beyond the rightmost column in generic wxHeaderCtrl Dragging a column header in a wxHeaderCtrl and dropping it past the rightmost column resulted in a crash due to accessing a column with invalid index. Fix this and correctly move the column to the last position when this happens instead. This bug notably affected dragging columns in wxGrid. Closes https://github.com/wxWidgets/wxWidgets/pull/972 --- include/wx/generic/headerctrlg.h | 4 ++++ src/generic/headerctrlg.cpp | 34 ++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/include/wx/generic/headerctrlg.h b/include/wx/generic/headerctrlg.h index 8a2a84ca1c..b145f1cbe2 100644 --- a/include/wx/generic/headerctrlg.h +++ b/include/wx/generic/headerctrlg.h @@ -98,6 +98,10 @@ private: // column 1 but close enough to the divider separating it from column 0) unsigned int FindColumnAtPoint(int x, bool *onSeparator = NULL) const; + // return the result of FindColumnAtPoint() if it is a valid column, + // otherwise the index of the last (rightmost) displayed column + unsigned int FindColumnClosestToPoint(int xPhysical) const; + // return true if a drag resizing operation is currently in progress bool IsResizing() const; diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index 6d86d56209..51ddad922e 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -208,6 +208,23 @@ unsigned int wxHeaderCtrl::FindColumnAtPoint(int xPhysical, bool *onSeparator) c return COL_NONE; } +unsigned int wxHeaderCtrl::FindColumnClosestToPoint(int xPhysical) const +{ + const unsigned int colIndexAtPoint = FindColumnAtPoint(xPhysical); + + // valid column found? + if ( colIndexAtPoint != COL_NONE ) + return colIndexAtPoint; + + // if not, xPhysical must be beyond the rightmost column, so return its + // index instead -- if we have it + const unsigned int count = GetColumnCount(); + if ( !count ) + return COL_NONE; + + return m_colIndices[count - 1]; +} + // ---------------------------------------------------------------------------- // wxHeaderCtrl repainting // ---------------------------------------------------------------------------- @@ -372,7 +389,7 @@ void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical) // and also a hint indicating where it is going to be inserted if it's // dropped now - unsigned int col = FindColumnAtPoint(xPhysical); + unsigned int col = FindColumnClosestToPoint(xPhysical); if ( col != COL_NONE ) { static const int DROP_MARKER_WIDTH = 4; @@ -414,15 +431,24 @@ bool wxHeaderCtrl::EndReordering(int xPhysical) ReleaseMouse(); - const int colOld = m_colBeingReordered, - colNew = FindColumnAtPoint(xPhysical); + const int colOld = m_colBeingReordered; + const unsigned colNew = FindColumnClosestToPoint(xPhysical); m_colBeingReordered = COL_NONE; + // mouse drag must be longer than min distance m_dragOffset if ( xPhysical - GetColStart(colOld) == m_dragOffset ) + { return false; + } - if ( colNew != colOld ) + // cannot proceed without a valid column index + if ( colNew == COL_NONE ) + { + return false; + } + + if ( static_cast(colNew) != colOld ) { wxHeaderCtrlEvent event(wxEVT_HEADER_END_REORDER, GetId()); event.SetEventObject(this); From 65ac801c400cdf644f775e42762a0cff1299d6d2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 12 Nov 2018 00:10:56 +0100 Subject: [PATCH 059/140] Make separator click sensitivity in wxHeaderCtrl DPI-dependent Sensitivity should be greater for high DPI displays to allow the user clicking as far from the separator in this case as with standard DPI. Also define a named constant for this value instead of using it directly. See https://github.com/wxWidgets/wxWidgets/pull/972 --- src/generic/headerctrlg.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index 51ddad922e..0bcc66593f 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -183,11 +183,12 @@ unsigned int wxHeaderCtrl::FindColumnAtPoint(int xPhysical, bool *onSeparator) c pos += col.GetWidth(); + // TODO: don't hardcode sensitivity + const int separatorClickMargin = FromDIP(8); + // if the column is resizable, check if we're approximatively over the // line separating it from the next column - // - // TODO: don't hardcode sensitivity - if ( col.IsResizeable() && abs(xLogical - pos) < 8 ) + if ( col.IsResizeable() && abs(xLogical - pos) < separatorClickMargin ) { if ( onSeparator ) *onSeparator = true; From 3e50405b5fe0a15000ad9e6bf3815a94048a696b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 12 Nov 2018 23:18:08 +0100 Subject: [PATCH 060/140] Update index of selected item of wxOwnerDrawnComboBox popup on inserting new item We have to update index of the currently selected item if value of inserted item is the same as the value of currently selected item (we take lower index in this case) or if new item is inserted before the current selection (current selection index has to be increased in this case). Closes #14153. --- src/generic/odcombo.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 4f144bb751..8ae5075e20 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -515,11 +515,13 @@ void wxVListBoxComboPopup::OnChar(wxKeyEvent& event) void wxVListBoxComboPopup::Insert( const wxString& item, int pos ) { // Need to change selection? - wxString strValue; - if ( !(m_combo->GetWindowStyle() & wxCB_READONLY) && - m_combo->GetValue() == item ) + if ( m_combo->GetValue() == item ) { - m_value = pos; + m_value = wxMin(m_value, pos); + } + else if ( pos <= m_value ) + { + m_value++; } m_strings.Insert(item,pos); From dfc5b35b040698640ac144fd2124b04ea49bb2e3 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 12 Nov 2018 23:42:32 +0100 Subject: [PATCH 061/140] Don't make a local copy of the entire array Use reference to the member array instead. --- src/generic/odcombo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 8ae5075e20..fffb15a601 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -543,7 +543,7 @@ int wxVListBoxComboPopup::Append(const wxString& item) { // Find position // TODO: Could be optimized with binary search - wxArrayString strings = m_strings; + const wxArrayString& strings = m_strings; unsigned int i; for ( i=0; i Date: Mon, 12 Nov 2018 23:47:26 +0100 Subject: [PATCH 062/140] Reduce the scope of variables using to index the loops --- src/generic/odcombo.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index fffb15a601..dace6230a4 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -544,9 +544,7 @@ int wxVListBoxComboPopup::Append(const wxString& item) // Find position // TODO: Could be optimized with binary search const wxArrayString& strings = m_strings; - unsigned int i; - - for ( i=0; iGetFont(); dc.SetFont(m_useFont); - for ( i=0; i bestWidth ) @@ -849,11 +844,9 @@ wxSize wxVListBoxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int //void wxVListBoxComboPopup::Populate( int n, const wxString choices[] ) void wxVListBoxComboPopup::Populate( const wxArrayString& choices ) { - int i; - int n = choices.GetCount(); - for ( i=0; i Date: Tue, 13 Nov 2018 16:11:24 +0100 Subject: [PATCH 063/140] Fix error about duplicate PNG image handler in the drawing sample Add the handler earlier, as creating the handler main frame uses wxArtProvider::GetBitmap() which can add the PNG handler on some platforms (e.g. macOS, when using wxTangoArtProvider), so calling wxImage::AddHandler() again after creating the frame could result in a debug error message about adding the same handler twice. --- samples/drawing/drawing.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index b9da4ce65a..fd7e032661 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -461,6 +461,10 @@ bool MyApp::OnInit() if ( !wxApp::OnInit() ) return false; +#if wxUSE_LIBPNG + wxImage::AddHandler( new wxPNGHandler ); +#endif + // Create the main application window MyFrame *frame = new MyFrame("Drawing sample", wxDefaultPosition, wxSize(550, 840)); @@ -477,9 +481,6 @@ bool MyApp::OnInit() // still continue, the sample can be used without images too if they're // missing for whatever reason } -#if wxUSE_LIBPNG - wxImage::AddHandler( new wxPNGHandler ); -#endif return true; } From edecb268995a9f6d82d4a25818e440826c13eb6c Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 14 Nov 2018 12:06:36 +0100 Subject: [PATCH 064/140] adapting xcodeproj to generic imaglist.cpp --- build/osx/wxcocoa.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/osx/wxcocoa.xcodeproj/project.pbxproj b/build/osx/wxcocoa.xcodeproj/project.pbxproj index b713560798..a7b2275d59 100644 --- a/build/osx/wxcocoa.xcodeproj/project.pbxproj +++ b/build/osx/wxcocoa.xcodeproj/project.pbxproj @@ -3885,7 +3885,7 @@ 0116581B77DF3A5D889B8D17 /* dndcmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = dndcmn.cpp; path = ../../src/common/dndcmn.cpp; sourceTree = ""; }; 018B15DE6F3A3D49B9CDE9DE /* hidjoystick.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = hidjoystick.cpp; path = ../../src/osx/core/hidjoystick.cpp; sourceTree = ""; }; 01BA6D45FE4C381493EB4372 /* validate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = validate.cpp; path = ../../src/common/validate.cpp; sourceTree = ""; }; - 027D2F04BE933ED6B9BA1518 /* imaglist.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = imaglist.cpp; path = ../../src/osx/imaglist.cpp; sourceTree = ""; }; + 027D2F04BE933ED6B9BA1518 /* imaglist.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = imaglist.cpp; path = ../../src/generic/imaglist.cpp; sourceTree = ""; }; 029486D6A2EC3DE0902A6A24 /* jfdctfst.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = jfdctfst.c; path = ../../src/jpeg/jfdctfst.c; sourceTree = ""; }; 02D2E8B5C89939CE90B99E2B /* archive.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = archive.cpp; path = ../../src/common/archive.cpp; sourceTree = ""; }; 02D9332D5C5632E981936E29 /* jquant2.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = jquant2.c; path = ../../src/jpeg/jquant2.c; sourceTree = ""; }; From ae3e581bb9cdb449e36d89700d5b0531ad85d5f5 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 14 Nov 2018 21:25:51 +0100 Subject: [PATCH 065/140] Don't set wxComboCtrl value twice The value is set once in wxComboPopup::Dismiss() so there is no need to set it again and generate spurious EVT_TEXT event. See #18260. --- src/generic/odcombo.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index dace6230a4..7eb5692256 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -219,18 +219,15 @@ void wxVListBoxComboPopup::DismissWithEvent() int selection = wxVListBox::GetSelection(); - Dismiss(); - if ( selection != wxNOT_FOUND ) m_stringValue = m_strings[selection]; else m_stringValue.clear(); - if ( m_stringValue != m_combo->GetValue() ) - m_combo->SetValueByUser(m_stringValue); - m_value = selection; + Dismiss(); + SendComboBoxEvent(selection); } From c05fac0adef0edb018de617e77c72e8abbaf6b86 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 14 Nov 2018 21:30:34 +0100 Subject: [PATCH 066/140] Don't re-enter wxComboCtrlBase::HidePopup Under wxMSW this method is re-entered due to triggering EVT_ACTIVATE when EVT_LEFT_UP is being already handled. We need to prevent this to avoid generating spurious EVT_TEXT events and raising errors on calling SetFocus(). Closes #18260. --- include/wx/combo.h | 2 +- src/common/combocmn.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/wx/combo.h b/include/wx/combo.h index 9e26ddd318..2ba9780a2d 100644 --- a/include/wx/combo.h +++ b/include/wx/combo.h @@ -455,7 +455,7 @@ public: enum { Hidden = 0, - //Closing = 1, + Closing = 1, Animating = 2, Visible = 3 }; diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index b1e0645abd..faa28ab75a 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -2571,8 +2571,9 @@ void wxComboCtrlBase::OnPopupDismiss(bool generateEvent) void wxComboCtrlBase::HidePopup(bool generateEvent) { // Should be able to call this without popup interface - if ( IsPopupWindowState(Hidden) ) + if ( IsPopupWindowState(Hidden) || IsPopupWindowState(Closing) ) return; + m_popupWinState = Closing; // To prevent from reentering // transfer value and show it in textctrl, if any if ( !IsPopupWindowState(Animating) ) From ea7f86d9f7bb4101535fbb2479b549513cb9fef6 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 14 Nov 2018 22:37:15 +0100 Subject: [PATCH 067/140] Use wxVector instead of wxArrayInt --- include/wx/odcombo.h | 2 +- src/generic/odcombo.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/wx/odcombo.h b/include/wx/odcombo.h index 622e51a748..7fe4cddd8a 100644 --- a/include/wx/odcombo.h +++ b/include/wx/odcombo.h @@ -192,7 +192,7 @@ protected: private: // Cached item widths (in pixels). - wxArrayInt m_widths; + wxVector m_widths; // Width of currently widest item. int m_widestWidth; diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 7eb5692256..12fb482dec 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -525,7 +525,7 @@ void wxVListBoxComboPopup::Insert( const wxString& item, int pos ) if ( (int)m_clientDatas.size() >= pos ) m_clientDatas.Insert(NULL, pos); - m_widths.Insert(-1,pos); + m_widths.insert(m_widths.begin()+pos, -1); m_widthsDirty = true; if ( IsCreated() ) @@ -561,7 +561,7 @@ void wxVListBoxComboPopup::Clear() wxASSERT(m_combo); m_strings.Empty(); - m_widths.Empty(); + m_widths.clear(); m_widestWidth = 0; m_widestItem = -1; @@ -618,7 +618,7 @@ void wxVListBoxComboPopup::Delete( unsigned int item ) } m_strings.RemoveAt(item); - m_widths.RemoveAt(item); + m_widths.erase(m_widths.begin()+item); if ( (int)item == m_widestItem ) m_findWidest = true; @@ -712,9 +712,9 @@ void wxVListBoxComboPopup::CalcWidths() // Measure items with dirty width. if ( m_widthsDirty ) { - unsigned int n = m_widths.GetCount(); + unsigned int n = m_widths.size(); int dirtyHandled = 0; - wxArrayInt& widths = m_widths; + wxVector& widths = m_widths; // I think using wxDC::GetTextExtent is faster than // wxWindow::GetTextExtent (assuming same dc is used @@ -772,7 +772,7 @@ void wxVListBoxComboPopup::CalcWidths() if ( doFindWidest ) { - unsigned int n = m_widths.GetCount(); + unsigned int n = m_widths.size(); int bestWidth = -1; int bestIndex = -1; @@ -849,7 +849,7 @@ void wxVListBoxComboPopup::Populate( const wxArrayString& choices ) m_strings.Add(item); } - m_widths.SetCount(n,-1); + m_widths.resize(n,-1); m_widthsDirty = true; if ( IsCreated() ) From 1ba0f055e23963532ab0aef84ed89850b1e547f1 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 16 Nov 2018 18:51:36 +0100 Subject: [PATCH 068/140] Use dedicated function to get screen position of wxComboCtrl popup Closes #13462. --- src/common/combocmn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index faa28ab75a..4663dd5c0f 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -2277,7 +2277,7 @@ void wxComboCtrlBase::ShowPopup() wxSize ctrlSz = GetSize(); screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); - scrPos = GetParent()->ClientToScreen(GetPosition()); + scrPos = GetScreenPosition(); spaceAbove = scrPos.y; spaceBelow = screenHeight - spaceAbove - ctrlSz.y; From 0bcd7f9b51db7719b8325f888fd19ec488916d1a Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 16 Nov 2018 23:20:33 -0800 Subject: [PATCH 069/140] Fix sizing of generic windows in wxToolBar with GTK+3. Broken by ee0b07fc31a. See #18269 --- src/gtk/win_gtk.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gtk/win_gtk.cpp b/src/gtk/win_gtk.cpp index 98b17fe117..9057f30ed4 100644 --- a/src/gtk/win_gtk.cpp +++ b/src/gtk/win_gtk.cpp @@ -218,8 +218,6 @@ static void pizza_adjust_size_request(GtkWidget* widget, GtkOrientation orientat // will use the size request, if set, as the minimum. // But don't override if in a GtkToolbar, it uses the minimum as actual size. GtkWidget* parent = gtk_widget_get_parent(widget); - if (parent) - parent = gtk_widget_get_parent(parent); if (!GTK_IS_TOOL_ITEM(parent)) *minimum = 0; } From de57bcd1bc4726cb172e238f64d4216b2aa65a36 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 16 Nov 2018 23:25:31 -0800 Subject: [PATCH 070/140] Fix drawing background before drawing toolbar bitmap The Cairo origin is already set up for the widget --- src/gtk/toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gtk/toolbar.cpp b/src/gtk/toolbar.cpp index d6d399b4a7..df9733c111 100644 --- a/src/gtk/toolbar.cpp +++ b/src/gtk/toolbar.cpp @@ -196,7 +196,7 @@ image_expose_event(GtkWidget* widget, GdkEventExpose*, wxToolBarTool* tool) int y = (alloc.height - bitmap.GetScaledHeight()) / 2; #ifdef __WXGTK3__ gtk_render_background(gtk_widget_get_style_context(widget), - cr, alloc.x, alloc.y, alloc.width, alloc.height); + cr, 0, 0, alloc.width, alloc.height); bitmap.Draw(cr, x, y); #else x += alloc.x; From 29bd2c92747f7bd53c74610f0683cc3e91ffbc17 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 16 Nov 2018 23:31:30 -0800 Subject: [PATCH 071/140] Don't avoid stock items with GTK+3 They still work fine with GTK+3, we just have to avoid them with GTK+4 --- src/gtk/button.cpp | 18 ++++++++++++------ src/gtk/dirdlg.cpp | 14 ++++++++++---- src/gtk/filedlg.cpp | 18 ++++++++++++------ src/gtk/msgdlg.cpp | 34 ++++++++++++++++++++++------------ 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 247c5150b8..97c4bc93e9 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -179,12 +179,14 @@ wxSize wxButtonBase::GetDefaultSize() GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ wxString labelGTK = GTKConvertMnemonics(wxGetStockLabel(wxID_CANCEL)); GtkWidget *btn = gtk_button_new_with_mnemonic(labelGTK.utf8_str()); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) GtkWidget *btn = gtk_button_new_from_stock(GTK_STOCK_CANCEL); -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif gtk_container_add(GTK_CONTAINER(box), btn); gtk_container_add(GTK_CONTAINER(wnd), box); GtkRequisition req; @@ -219,7 +221,8 @@ void wxButton::SetLabel( const wxString &lbl ) if ( HasFlag(wxBU_NOTEXT) ) return; -#if !defined(__WXGTK3__) || !GTK_CHECK_VERSION(3,10,0) +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) if (wxIsStockID(m_windowId) && wxIsStockLabel(m_windowId, label)) { const char *stock = wxGetStockGtkID(m_windowId); @@ -230,7 +233,8 @@ void wxButton::SetLabel( const wxString &lbl ) return; } } -#endif // GTK < 3.10 + wxGCC_WARNING_RESTORE() +#endif // this call is necessary if the button had been initially created without // a (text) label -- then we didn't use gtk_button_new_with_mnemonic() and @@ -238,9 +242,11 @@ void wxButton::SetLabel( const wxString &lbl ) gtk_button_set_use_underline(GTK_BUTTON(m_widget), TRUE); const wxString labelGTK = GTKConvertMnemonics(label); gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK)); -#if !defined(__WXGTK3__) || !GTK_CHECK_VERSION(3,10,0) +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) gtk_button_set_use_stock(GTK_BUTTON(m_widget), FALSE); -#endif // GTK < 3.10 + wxGCC_WARNING_RESTORE() +#endif GTKApplyWidgetStyle( false ); } diff --git a/src/gtk/dirdlg.cpp b/src/gtk/dirdlg.cpp index 04e9401c68..3514cc406e 100644 --- a/src/gtk/dirdlg.cpp +++ b/src/gtk/dirdlg.cpp @@ -85,23 +85,29 @@ bool wxDirDialog::Create(wxWindow* parent, if (parent) gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) +#endif m_widget = gtk_file_chooser_dialog_new( wxGTK_CONV(m_message), gtk_parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ static_cast(wxGTK_CONV(wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_CANCEL)))), #else GTK_STOCK_CANCEL, -#endif // GTK >= 3.10 / < 3.10 +#endif GTK_RESPONSE_CANCEL, -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ static_cast(wxGTK_CONV(wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_OPEN)))), #else GTK_STOCK_OPEN, -#endif // GTK >= 3.10 / < 3.10 +#endif GTK_RESPONSE_ACCEPT, NULL); +#ifndef __WXGTK4__ + wxGCC_WARNING_RESTORE() +#endif g_object_ref(m_widget); gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT); diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 7aa39cdfb3..05449efc65 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -213,38 +213,44 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message, if (parent) gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) +#endif wxString ok_btn_stock; if ( style & wxFD_SAVE ) { gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE; -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ ok_btn_stock = wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_SAVE)); #else ok_btn_stock = GTK_STOCK_SAVE; -#endif // GTK >= 3.10 / < 3.10 +#endif } else { gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN; -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ ok_btn_stock = wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_OPEN)); #else ok_btn_stock = GTK_STOCK_OPEN; -#endif // GTK >= 3.10 / < 3.10 +#endif } m_widget = gtk_file_chooser_dialog_new( wxGTK_CONV(m_message), gtk_parent, gtk_action, -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ static_cast(wxGTK_CONV(wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_CANCEL)))), #else GTK_STOCK_CANCEL, -#endif // GTK >= 3.10 / < 3.10 +#endif GTK_RESPONSE_CANCEL, static_cast(wxGTK_CONV(ok_btn_stock)), GTK_RESPONSE_ACCEPT, NULL); +#ifndef __WXGTK4__ + wxGCC_WARNING_RESTORE() +#endif g_object_ref(m_widget); GtkFileChooser* file_chooser = GTK_FILE_CHOOSER(m_widget); diff --git a/src/gtk/msgdlg.cpp b/src/gtk/msgdlg.cpp index 77d2d6a0ea..25d67009f8 100644 --- a/src/gtk/msgdlg.cpp +++ b/src/gtk/msgdlg.cpp @@ -49,47 +49,57 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, wxString wxMessageDialog::GetDefaultYesLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_YES)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_YES; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultNoLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_NO)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_NO; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultOKLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_OK)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_OK; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultCancelLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_CANCEL)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_CANCEL; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultHelpLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_HELP)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_HELP; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } void wxMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& label) @@ -102,11 +112,11 @@ void wxMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& label) } else // stock label { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ var = wxConvertMnemonicsToGTK(wxGetStockLabel(stockId)); #else var = wxGetStockGtkID(stockId); -#endif // GTK >= 3.10 / < 3.10 +#endif } } From c0febe1fcefd2a3336f2c6342c32b99c61ffb89b Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Fri, 16 Nov 2018 20:49:56 +0100 Subject: [PATCH 072/140] Update expat submodule --- src/expat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/expat b/src/expat index 6b2e0e6802..b99766ce61 160000 --- a/src/expat +++ b/src/expat @@ -1 +1 @@ -Subproject commit 6b2e0e680289cdf92839b2a3f8b0735c84dc9326 +Subproject commit b99766ce61f2cefa0ada22204765c1bf08802216 From 9b8ed6a0219adb9062a879c888dfe8e2381fccc9 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 17 Nov 2018 15:24:31 +0100 Subject: [PATCH 073/140] Update png submodule --- src/png | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/png b/src/png index a016282f47..772e393c7e 160000 --- a/src/png +++ b/src/png @@ -1 +1 @@ -Subproject commit a016282f4752b1177da5722efda7e3045a4ecdf1 +Subproject commit 772e393c7eb95f0424d2d895abd5f8ad0131f500 From ec4b71afa0e362450716a4dc46f783c429f5c171 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 17 Nov 2018 15:27:31 +0100 Subject: [PATCH 074/140] Update tiff submodule Add the new files to the build system. Disable support for webp and zstd because we do not want to depend on external libraries. --- Makefile.in | 10 +++++++++- build/bakefiles/tiff.bkl | 2 ++ build/cmake/lib/tiff.cmake | 2 ++ build/msw/makefile.bcc | 10 +++++++++- build/msw/makefile.gcc | 10 +++++++++- build/msw/makefile.vc | 10 +++++++++- build/msw/wx_vc7_wxtiff.vcproj | 6 ++++++ build/msw/wx_vc8_wxtiff.vcproj | 8 ++++++++ build/msw/wx_vc9_wxtiff.vcproj | 8 ++++++++ configure | 7 +++++-- configure.in | 15 +++++++++------ src/tiff | 2 +- 12 files changed, 77 insertions(+), 13 deletions(-) diff --git a/Makefile.in b/Makefile.in index 04eaa957f2..e44bc57695 100644 --- a/Makefile.in +++ b/Makefile.in @@ -206,8 +206,10 @@ WXTIFF_OBJECTS = \ wxtiff_tif_tile.o \ wxtiff_tif_version.o \ wxtiff_tif_warning.o \ + wxtiff_tif_webp.o \ wxtiff_tif_write.o \ - wxtiff_tif_zip.o + wxtiff_tif_zip.o \ + wxtiff_tif_zstd.o WXEXPAT_CFLAGS = -DNDEBUG -I./src/expat/expat -DHAVE_EXPAT_CONFIG_H \ $(____SHARED) $(CPPFLAGS) $(CFLAGS) WXEXPAT_OBJECTS = \ @@ -15026,12 +15028,18 @@ wxtiff_tif_version.o: $(srcdir)/src/tiff/libtiff/tif_version.c wxtiff_tif_warning.o: $(srcdir)/src/tiff/libtiff/tif_warning.c $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_warning.c +wxtiff_tif_webp.o: $(srcdir)/src/tiff/libtiff/tif_webp.c + $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_webp.c + wxtiff_tif_write.o: $(srcdir)/src/tiff/libtiff/tif_write.c $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_write.c wxtiff_tif_zip.o: $(srcdir)/src/tiff/libtiff/tif_zip.c $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_zip.c +wxtiff_tif_zstd.o: $(srcdir)/src/tiff/libtiff/tif_zstd.c + $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_zstd.c + @COND_PLATFORM_UNIX_1@wxtiff_tif_unix.o: $(srcdir)/src/tiff/libtiff/tif_unix.c @COND_PLATFORM_UNIX_1@ $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_unix.c diff --git a/build/bakefiles/tiff.bkl b/build/bakefiles/tiff.bkl index df6629e34f..ae321f4439 100644 --- a/build/bakefiles/tiff.bkl +++ b/build/bakefiles/tiff.bkl @@ -93,8 +93,10 @@ src/tiff/libtiff/tif_tile.c src/tiff/libtiff/tif_version.c src/tiff/libtiff/tif_warning.c + src/tiff/libtiff/tif_webp.c src/tiff/libtiff/tif_write.c src/tiff/libtiff/tif_zip.c + src/tiff/libtiff/tif_zstd.c diff --git a/build/cmake/lib/tiff.cmake b/build/cmake/lib/tiff.cmake index d1ef8d51f6..289390db73 100644 --- a/build/cmake/lib/tiff.cmake +++ b/build/cmake/lib/tiff.cmake @@ -59,8 +59,10 @@ if(wxUSE_LIBTIFF STREQUAL "builtin") src/tiff/libtiff/tif_tile.c src/tiff/libtiff/tif_version.c src/tiff/libtiff/tif_warning.c + src/tiff/libtiff/tif_webp.c src/tiff/libtiff/tif_write.c src/tiff/libtiff/tif_zip.c + src/tiff/libtiff/tif_zstd.c ) if(WIN32) # define this to get rid of a warning about using POSIX lfind(): diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 24a3687ebe..8112f30f89 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -185,8 +185,10 @@ WXTIFF_OBJECTS = \ $(OBJS)\wxtiff_tif_tile.obj \ $(OBJS)\wxtiff_tif_version.obj \ $(OBJS)\wxtiff_tif_warning.obj \ + $(OBJS)\wxtiff_tif_webp.obj \ $(OBJS)\wxtiff_tif_write.obj \ - $(OBJS)\wxtiff_tif_zip.obj + $(OBJS)\wxtiff_tif_zip.obj \ + $(OBJS)\wxtiff_tif_zstd.obj WXEXPAT_CFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ $(__OPTIMIZEFLAG) $(__THREADSFLAG) -DNDEBUG -I$(LIBDIRNAME) -w-8004 -w-8008 \ -w-8012 -w-8057 -w-8066 $(CPPFLAGS) $(CFLAGS) @@ -5950,12 +5952,18 @@ $(OBJS)\wxtiff_tif_version.obj: ..\..\src\tiff\libtiff\tif_version.c $(OBJS)\wxtiff_tif_warning.obj: ..\..\src\tiff\libtiff\tif_warning.c $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_warning.c +$(OBJS)\wxtiff_tif_webp.obj: ..\..\src\tiff\libtiff\tif_webp.c + $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_webp.c + $(OBJS)\wxtiff_tif_write.obj: ..\..\src\tiff\libtiff\tif_write.c $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_write.c $(OBJS)\wxtiff_tif_zip.obj: ..\..\src\tiff\libtiff\tif_zip.c $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zip.c +$(OBJS)\wxtiff_tif_zstd.obj: ..\..\src\tiff\libtiff\tif_zstd.c + $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zstd.c + $(OBJS)\wxexpat_xmlparse.obj: ..\..\src\expat\expat\lib\xmlparse.c $(CC) -q -c -P- -o$@ $(WXEXPAT_CFLAGS) ..\..\src\expat\expat\lib\xmlparse.c diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 18792ec66d..c6a2042c6b 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -174,8 +174,10 @@ WXTIFF_OBJECTS = \ $(OBJS)\wxtiff_tif_tile.o \ $(OBJS)\wxtiff_tif_version.o \ $(OBJS)\wxtiff_tif_warning.o \ + $(OBJS)\wxtiff_tif_webp.o \ $(OBJS)\wxtiff_tif_write.o \ - $(OBJS)\wxtiff_tif_zip.o + $(OBJS)\wxtiff_tif_zip.o \ + $(OBJS)\wxtiff_tif_zstd.o WXEXPAT_CFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) $(GCCFLAGS) \ -DHAVE_W32API_H -DNDEBUG -I$(LIBDIRNAME) $(CPPFLAGS) $(CFLAGS) WXEXPAT_OBJECTS = \ @@ -6132,12 +6134,18 @@ $(OBJS)\wxtiff_tif_version.o: ../../src/tiff/libtiff/tif_version.c $(OBJS)\wxtiff_tif_warning.o: ../../src/tiff/libtiff/tif_warning.c $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< +$(OBJS)\wxtiff_tif_webp.o: ../../src/tiff/libtiff/tif_webp.c + $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< + $(OBJS)\wxtiff_tif_write.o: ../../src/tiff/libtiff/tif_write.c $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< $(OBJS)\wxtiff_tif_zip.o: ../../src/tiff/libtiff/tif_zip.c $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< +$(OBJS)\wxtiff_tif_zstd.o: ../../src/tiff/libtiff/tif_zstd.c + $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< + $(OBJS)\wxexpat_xmlparse.o: ../../src/expat/expat/lib/xmlparse.c $(CC) -c -o $@ $(WXEXPAT_CFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index 60db1ec578..c1ce7f10bd 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -191,8 +191,10 @@ WXTIFF_OBJECTS = \ $(OBJS)\wxtiff_tif_tile.obj \ $(OBJS)\wxtiff_tif_version.obj \ $(OBJS)\wxtiff_tif_warning.obj \ + $(OBJS)\wxtiff_tif_webp.obj \ $(OBJS)\wxtiff_tif_write.obj \ - $(OBJS)\wxtiff_tif_zip.obj + $(OBJS)\wxtiff_tif_zip.obj \ + $(OBJS)\wxtiff_tif_zstd.obj WXEXPAT_CFLAGS = /M$(__RUNTIME_LIBS_85)$(__DEBUGRUNTIME) /DWIN32 \ $(__DEBUGINFO) /Fd$(LIBDIRNAME)\wxexpat$(WXDEBUGFLAG).pdb \ $(____DEBUGRUNTIME) $(__OPTIMIZEFLAG) /D_CRT_SECURE_NO_DEPRECATE=1 \ @@ -6659,12 +6661,18 @@ $(OBJS)\wxtiff_tif_version.obj: ..\..\src\tiff\libtiff\tif_version.c $(OBJS)\wxtiff_tif_warning.obj: ..\..\src\tiff\libtiff\tif_warning.c $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_warning.c +$(OBJS)\wxtiff_tif_webp.obj: ..\..\src\tiff\libtiff\tif_webp.c + $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_webp.c + $(OBJS)\wxtiff_tif_write.obj: ..\..\src\tiff\libtiff\tif_write.c $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_write.c $(OBJS)\wxtiff_tif_zip.obj: ..\..\src\tiff\libtiff\tif_zip.c $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zip.c +$(OBJS)\wxtiff_tif_zstd.obj: ..\..\src\tiff\libtiff\tif_zstd.c + $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zstd.c + $(OBJS)\wxexpat_xmlparse.obj: ..\..\src\expat\expat\lib\xmlparse.c $(CC) /c /nologo /TC /Fo$@ $(WXEXPAT_CFLAGS) ..\..\src\expat\expat\lib\xmlparse.c diff --git a/build/msw/wx_vc7_wxtiff.vcproj b/build/msw/wx_vc7_wxtiff.vcproj index 24ff2fe8e7..e38387d7e3 100644 --- a/build/msw/wx_vc7_wxtiff.vcproj +++ b/build/msw/wx_vc7_wxtiff.vcproj @@ -351,6 +351,9 @@ + + @@ -360,6 +363,9 @@ + + diff --git a/build/msw/wx_vc8_wxtiff.vcproj b/build/msw/wx_vc8_wxtiff.vcproj index a0dd040d57..ad88651710 100644 --- a/build/msw/wx_vc8_wxtiff.vcproj +++ b/build/msw/wx_vc8_wxtiff.vcproj @@ -814,6 +814,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_warning.c" > + + @@ -826,6 +830,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_zip.c" > + + diff --git a/build/msw/wx_vc9_wxtiff.vcproj b/build/msw/wx_vc9_wxtiff.vcproj index 98b10bf9d5..bd58142dbc 100644 --- a/build/msw/wx_vc9_wxtiff.vcproj +++ b/build/msw/wx_vc9_wxtiff.vcproj @@ -810,6 +810,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_warning.c" > + + @@ -822,6 +826,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_zip.c" > + + diff --git a/configure b/configure index 2378cc74fd..18146f9527 100755 --- a/configure +++ b/configure @@ -23373,8 +23373,11 @@ fi fi fi -if test "$wxUSE_LIBLZMA" = "no" -a "$wxUSE_LIBTIFF" = "builtin"; then - ac_configure_args="$ac_configure_args --disable-lzma" +if test "$wxUSE_LIBTIFF" = "builtin"; then + ac_configure_args="$ac_configure_args --disable-webp --disable-zstd" + if test "$wxUSE_LIBLZMA" = "no"; then + ac_configure_args="$ac_configure_args --disable-lzma" + fi fi diff --git a/configure.in b/configure.in index 1159b013c6..2c91781ff0 100644 --- a/configure.in +++ b/configure.in @@ -2585,12 +2585,15 @@ if test "$wxUSE_LIBLZMA" != "no"; then fi fi -dnl We need to disable the use of lzma in built-in libtiff explicitly, as -dnl otherwise we'd depend on the system lzma library, which is typically -dnl undesirable when using builtin libraries. We also disable the use of lzma -dnl if it's not available anyhow, just to speed up libtiff configure a little. -if test "$wxUSE_LIBLZMA" = "no" -a "$wxUSE_LIBTIFF" = "builtin"; then - ac_configure_args="$ac_configure_args --disable-lzma" +dnl Disable the use of lzma, webp and zstd in built-in libtiff explicitly, as +dnl otherwise we'd depend on the system libraries, which is typically +dnl undesirable when using builtin libraries. If we use lzma ourselves, keep it +dnl enabled. +if test "$wxUSE_LIBTIFF" = "builtin"; then + ac_configure_args="$ac_configure_args --disable-webp --disable-zstd" + if test "$wxUSE_LIBLZMA" = "no"; then + ac_configure_args="$ac_configure_args --disable-lzma" + fi fi dnl ------------------------------------------------------------------------ diff --git a/src/tiff b/src/tiff index aa65abe076..c70cb3d7b4 160000 --- a/src/tiff +++ b/src/tiff @@ -1 +1 @@ -Subproject commit aa65abe0762209d40ec5d4343ec426a4d67caf2d +Subproject commit c70cb3d7b4c861083cdc0b6f245f3830c6e42566 From aa8ce7acb145af76fb270800babd8bffc61865e1 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 17 Nov 2018 15:28:29 +0100 Subject: [PATCH 075/140] Include minor version in jpeg library version info --- src/common/imagjpeg.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/imagjpeg.cpp b/src/common/imagjpeg.cpp index df9893c44d..7fbb97ce5e 100644 --- a/src/common/imagjpeg.cpp +++ b/src/common/imagjpeg.cpp @@ -505,7 +505,11 @@ bool wxJPEGHandler::DoCanRead( wxInputStream& stream ) /*static*/ wxVersionInfo wxJPEGHandler::GetLibraryVersionInfo() { - return wxVersionInfo("libjpeg", JPEG_LIB_VERSION/10, JPEG_LIB_VERSION%10); +#if defined(JPEG_LIB_VERSION_MAJOR) && defined(JPEG_LIB_VERSION_MINOR) + return wxVersionInfo("libjpeg", JPEG_LIB_VERSION_MAJOR, JPEG_LIB_VERSION_MINOR); +#else + return wxVersionInfo("libjpeg", JPEG_LIB_VERSION / 10, JPEG_LIB_VERSION % 10); +#endif } #endif // wxUSE_LIBJPEG From 4ddd4cc68d7f93db1d5a83abbb338fc61a70dd24 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 17 Nov 2018 15:38:06 +0100 Subject: [PATCH 076/140] Improve updating third party library documentation Add a section about updating the build files. --- .../contributing/how-to-update-third-party-library.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/contributing/how-to-update-third-party-library.md b/docs/contributing/how-to-update-third-party-library.md index ad9dde29bd..0736502714 100644 --- a/docs/contributing/how-to-update-third-party-library.md +++ b/docs/contributing/how-to-update-third-party-library.md @@ -42,7 +42,14 @@ one: $ git push --set-upstream git@github.com:wxWidgets/libexpat.git wx -3. Updating the main repository +3. Generating build files (libexpat, libtiff) +--------------------------------------------- + +We include the generated build files of libexpat and libtiff. For libexpat run +`buildconf.sh`. For libtiff run `autogen.sh`. Commit the changes. + + +4. Updating the main repository ------------------------------- If there are any changes to the source files used by the library, update the @@ -54,7 +61,7 @@ manually. Commit these changes and the submodule and create a PR to test them as usual. -4. Special instructions for libpng +5. Special instructions for libpng ---------------------------------- We use a special hack for libpng as we want to prefix all its symbols with From 27d7dd3f00b4d002234b6a99ce8ac3f3953bc4a2 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 17 Nov 2018 16:05:52 +0100 Subject: [PATCH 077/140] Update catch submodule --- 3rdparty/catch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/catch b/3rdparty/catch index 011f6e6458..b46f260f81 160000 --- a/3rdparty/catch +++ b/3rdparty/catch @@ -1 +1 @@ -Subproject commit 011f6e6458d888246f94643e293f002073cff489 +Subproject commit b46f260f810bb693825c026269636e82b0a50722 From 660fbca82dd73eaf736dbc165ca1143519d80f41 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 17 Nov 2018 19:28:27 +0100 Subject: [PATCH 078/140] CMake: Add include directories and libraries for all packages lzma.h could not be found when building with wxUSE_LIBLZMA on macOS. Add the found include directories and libraries from find_package(LibLZMA) to the base library. For consistency, add the include directories and libraries of all find_package usage. Closes https://github.com/wxWidgets/wxWidgets/pull/1024 --- build/cmake/lib/base/CMakeLists.txt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/build/cmake/lib/base/CMakeLists.txt b/build/cmake/lib/base/CMakeLists.txt index ec38b8947a..0cf6a46860 100644 --- a/build/cmake/lib/base/CMakeLists.txt +++ b/build/cmake/lib/base/CMakeLists.txt @@ -27,28 +27,35 @@ elseif(UNIX) endif() wx_add_library(base IS_BASE ${BASE_FILES}) -wx_lib_link_libraries(base PRIVATE - ${ZLIB_LIBRARIES} - ${REGEX_LIBRARIES} -) + if(NOT wxBUILD_MONOLITHIC) wx_lib_compile_definitions(base PRIVATE wxUSE_BASE=1) endif() if(wxUSE_ZLIB) + wx_lib_include_directories(base PRIVATE ${ZLIB_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${ZLIB_LIBRARIES}) endif() if(wxUSE_REGEX) wx_lib_include_directories(base PRIVATE ${REGEX_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${REGEX_LIBRARIES}) endif() -if(LIBSECRET_FOUND) +if(wxUSE_LIBLZMA) + wx_lib_include_directories(base PRIVATE ${LIBLZMA_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${LIBLZMA_LIBRARIES}) +endif() +if(UNIX AND wxUSE_SECRETSTORE) wx_lib_include_directories(base PRIVATE ${LIBSECRET_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${LIBSECRET_LIBRARIES}) endif() if(wxUSE_LIBICONV AND ICONV_LIBRARIES) + wx_lib_include_directories(base PRIVATE ${ICONV_INCLUDE_DIRS}) wx_lib_link_libraries(base PRIVATE ${ICONV_LIBRARIES}) endif() if(wxUSE_THREADS AND CMAKE_THREAD_LIBS_INIT) wx_lib_link_libraries(base PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endif() + if(APPLE) wx_lib_link_libraries(base PRIVATE @@ -60,10 +67,7 @@ if(APPLE) "-framework IOKit" ) elseif(UNIX) - wx_lib_link_libraries(base PRIVATE - dl - ${LIBSECRET_LIBRARIES} - ) + wx_lib_link_libraries(base PRIVATE dl) endif() wx_finalize_lib(base) From a28b48ffe18a52d6de003216587fb71ea00783d9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 9 Nov 2018 01:50:44 +0100 Subject: [PATCH 079/140] Fix formatting in MSW install instructions Use backticks around _UNICODE to avoid the special meaning of "_" in Markdown. Also use backticks around a couple of other identifiers/paths for consistency. --- docs/msw/install.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/msw/install.md b/docs/msw/install.md index 2399ffbbe2..83f9829d6a 100644 --- a/docs/msw/install.md +++ b/docs/msw/install.md @@ -271,7 +271,7 @@ debugger is very good. To avoid linker errors you will need to add The version 5.6 included in Borland C++ Builder 2006 works as well after the following small change: please remove the test for `__WINDOWS__` from line 88 -of the file BCCDIR\include\stl\_threads.h. +of the file `BCCDIR\include\stl\_threads.h`. Compiling using the makefiles: @@ -535,11 +535,11 @@ Here is what you need to do: be used for debug builds only. * Define the following symbols for the preprocessor: - `__WXMSW__` to ensure you use the correct wxWidgets port. - - _UNICODE unless you want to use deprecated ANSI build of wxWidgets. - - NDEBUG if you want to build in release mode, i.e. disable asserts. - - WXUSINGDLL if you are using DLL build of wxWidgets. + - `_UNICODE` unless you want to use deprecated ANSI build of wxWidgets. + - `NDEBUG` if you want to build in release mode, i.e. disable asserts. + - `WXUSINGDLL` if you are using DLL build of wxWidgets. * If using MSVC 7 only (i.e. not for later versions), also define - wxUSE_RC_MANIFEST=1 and WX_CPU_X86. + `wxUSE_RC_MANIFEST=1` and `WX_CPU_X86`. * Add \ directory described above to the libraries path. When using MSVC, the libraries are linked automatically using "#pragma From 4099e75edb86948a46963511401dc3025e883183 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 9 Nov 2018 02:00:16 +0100 Subject: [PATCH 080/140] Add property sheet to allow easily configure projects using wx This seems to be the simplest possible way to let a MSVS project use the library. --- docs/changes.txt | 1 + docs/msw/install.md | 4 ++++ wxwidgets.props | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 wxwidgets.props diff --git a/docs/changes.txt b/docs/changes.txt index 99f65b57d3..b414530c9c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -168,6 +168,7 @@ wxMSW: - Improve wxNotebook themed background drawing (Arrigo Marchiori). - Send wxEVT_WEBVIEW_NAVIGATING when redirecting (Josue Andrade Gomes). - Fix build with MSVS 2005 broken in 3.1.1. +- Add wxwidgets.props property sheet file for MSVS users. wxOSX: diff --git a/docs/msw/install.md b/docs/msw/install.md index 83f9829d6a..d06c5c10e2 100644 --- a/docs/msw/install.md +++ b/docs/msw/install.md @@ -505,6 +505,10 @@ The full list of the build settings follows: Building Applications Using wxWidgets {#msw_build_apps} ===================================== +If you use MSVS 2010 or later IDE for building your project, simply add +`wxwidgets.props` property sheet to (all) your project(s) using wxWidgets. +You don't need to do anything else. + If you want to use CMake for building your project, please see @ref overview_cmake. diff --git a/wxwidgets.props b/wxwidgets.props new file mode 100644 index 0000000000..074d6b8a30 --- /dev/null +++ b/wxwidgets.props @@ -0,0 +1,30 @@ + + + + + + + + + WXUSINGDLL + + + + __WXMSW__;$(wxUsingDllDefine);%(PreprocessorDefinitions) + $(MSBuildThisFileDirectory)include\msvc;$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + __WXMSW__;$(wxUsingDllDefine);%(PreprocessorDefinitions) + $(MSBuildThisFileDirectory)lib\$(wxOutDirName)\$(wxToolkitPrefix)$(wxSuffix);$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)lib\$(wxOutDirName);%(AdditionalLibraryDirectories) + + + From 5d08e404c76c1745e070d9c96055b90ffddd7177 Mon Sep 17 00:00:00 2001 From: Lauri Nurmi Date: Tue, 2 Oct 2018 19:49:50 +0300 Subject: [PATCH 081/140] Allow getting all usable translations languages Add a method to return the full list of translations that can be used, generalizing the existing GetBestTranslation(). --- include/wx/translation.h | 5 ++++ interface/wx/translation.h | 43 +++++++++++++++++++++++++++ src/common/translation.cpp | 59 ++++++++++++++++++++++++++------------ 3 files changed, 89 insertions(+), 18 deletions(-) diff --git a/include/wx/translation.h b/include/wx/translation.h index 3d5d5b0b83..266166019c 100644 --- a/include/wx/translation.h +++ b/include/wx/translation.h @@ -145,6 +145,11 @@ public: wxString GetBestTranslation(const wxString& domain, const wxString& msgIdLanguage = "en"); + // find best and all other suitable translation languages for given domain + wxArrayString GetAllGoodTranslations(const wxString& domain, wxLanguage msgIdLanguage); + wxArrayString GetAllGoodTranslations(const wxString& domain, + const wxString& msgIdLanguage = "en"); + // add standard wxWidgets catalog ("wxstd") bool AddStdCatalog(); diff --git a/interface/wx/translation.h b/interface/wx/translation.h index eed6355d0b..a57c9930d0 100644 --- a/interface/wx/translation.h +++ b/interface/wx/translation.h @@ -137,6 +137,49 @@ public: const wxString& msgIdLanguage = "en"); /** + Returns the best and all other suitable UI languages for the @a domain. + + This is nearly the same as GetBestTranslation(), but returns the + whole list of preferred UI languages for which a translation for the + @a domain was found. + + @param domain + The catalog domain to look for. + + @param msgIdLanguage + Specifies the language of "msgid" strings in source code + (i.e. arguments to GetString(), wxGetTranslation() and the _() macro). + + @return An array of language codes if any suitable matches were found, empty array + otherwise. + + @since 3.1.2 + */ + wxArrayString GetAllGoodTranslations(const wxString& domain, wxLanguage msgIdLanguage); + + /** + Returns the best and all other suitable UI languages for the @a domain. + + This is nearly the same as GetBestTranslation(), but returns the + whole list of preferred UI languages for which a translation for the + @a domain was found. + + @param domain + The catalog domain to look for. + + @param msgIdLanguage + Specifies the language of "msgid" strings in source code + (i.e. arguments to GetString(), wxGetTranslation() and the _() macro). + + @return An array of language codes if any suitable matches were found, empty array + otherwise. + + @since 3.1.2 + */ + wxArrayString GetAllGoodTranslations(const wxString& domain, + const wxString& msgIdLanguage = "en"); + + /** Add standard wxWidgets catalogs ("wxstd" and possible port-specific catalogs). diff --git a/src/common/translation.cpp b/src/common/translation.cpp index bf92ed2942..a64327eaef 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -127,7 +127,7 @@ wxString GetPreferredUILanguageFallback(const wxArrayString& WXUNUSED(available) #ifdef __WINDOWS__ -wxString GetPreferredUILanguage(const wxArrayString& available) +wxString GetPreferredUILanguage(const wxArrayString& available, wxArrayString& allPreferred) { typedef BOOL (WINAPI *GetUserPreferredUILanguages_t)(DWORD, PULONG, PWSTR, PULONG); static GetUserPreferredUILanguages_t s_pfnGetUserPreferredUILanguages = NULL; @@ -172,18 +172,20 @@ wxString GetPreferredUILanguage(const wxArrayString& available) wxString lang(*j); lang.Replace("-", "_"); if ( available.Index(lang, /*bCase=*/false) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); size_t pos = lang.find('_'); if ( pos != wxString::npos ) { lang = lang.substr(0, pos); if ( available.Index(lang, /*bCase=*/false) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); } } } } } + if ( !allPreferred.empty() ) + return allPreferred[0]; return GetPreferredUILanguageFallback(available); } @@ -207,7 +209,7 @@ void LogTraceArray(const char *prefix, CFArrayRef arr) #endif // wxUSE_LOG_TRACE -wxString GetPreferredUILanguage(const wxArrayString& available) +wxString GetPreferredUILanguage(const wxArrayString& available, wxArrayString &allPreferred) { wxStringToStringHashMap availableNormalized; wxCFRef availableArr( @@ -231,17 +233,19 @@ wxString GetPreferredUILanguage(const wxArrayString& available) LogTraceArray(" - system preferred languages", prefArr); unsigned prefArrLength = CFArrayGetCount(prefArr); - if ( prefArrLength > 0 ) + for ( size_t x = 0; x < prefArrLength; ++x ) { // Lookup the name in 'available' by index -- we need to get the // original value corresponding to the normalized one chosen. - wxString lang(wxCFStringRef::AsString((CFStringRef)CFArrayGetValueAtIndex(prefArr, 0))); + wxString lang(wxCFStringRef::AsString((CFStringRef)CFArrayGetValueAtIndex(prefArr, x))); wxStringToStringHashMap::const_iterator i = availableNormalized.find(lang); if ( i == availableNormalized.end() ) - return lang; + allPreferred.push_back(lang); else - return i->second; + allPreferred.push_back(i->second); } + if ( allPreferred.empty() == false ) + return allPreferred[0]; return GetPreferredUILanguageFallback(available); } @@ -255,7 +259,7 @@ wxString GetPreferredUILanguage(const wxArrayString& available) // The LANGUAGE variable may contain a colon separated list of language // codes in the order of preference. // http://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html -wxString GetPreferredUILanguage(const wxArrayString& available) +wxString GetPreferredUILanguage(const wxArrayString& available, wxArrayString &allPreferred) { wxString languageFromEnv; wxArrayString preferred; @@ -283,15 +287,17 @@ wxString GetPreferredUILanguage(const wxArrayString& available) { wxString lang(*j); if ( available.Index(lang) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); size_t pos = lang.find('_'); if ( pos != wxString::npos ) { lang = lang.substr(0, pos); if ( available.Index(lang) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); } } + if ( allPreferred.empty() == false ) + return allPreferred[0]; return GetPreferredUILanguageFallback(available); } @@ -1650,20 +1656,37 @@ wxString wxTranslations::GetBestTranslation(const wxString& domain, wxString wxTranslations::GetBestTranslation(const wxString& domain, const wxString& msgIdLanguage) { - // explicitly set language should always be respected - if ( !m_lang.empty() ) - return m_lang; + const wxArrayString allGoodOnes = GetAllGoodTranslations(domain, msgIdLanguage); + wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]); + return allGoodOnes[0]; +} + +wxArrayString wxTranslations::GetAllGoodTranslations(const wxString& domain, + wxLanguage msgIdLanguage) +{ + const wxString lang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); + return GetAllGoodTranslations(domain, lang); +} + +wxArrayString wxTranslations::GetAllGoodTranslations(const wxString& domain, + const wxString& msgIdLanguage) +{ wxArrayString available(GetAvailableTranslations(domain)); // it's OK to have duplicates, so just add msgid language available.push_back(msgIdLanguage); available.push_back(msgIdLanguage.BeforeFirst('_')); - wxLogTrace(TRACE_I18N, "choosing best language for domain '%s'", domain); + wxLogTrace(TRACE_I18N, "choosing best languages for domain '%s'", domain); LogTraceArray(" - available translations", available); - const wxString lang = GetPreferredUILanguage(available); - wxLogTrace(TRACE_I18N, " => using language '%s'", lang); - return lang; + wxArrayString allPreferred; + GetPreferredUILanguage(available, allPreferred); + + // explicitly set language should always be preferred the most + if ( !m_lang.empty() ) + allPreferred.insert(allPreferred.begin(), m_lang); + + return allPreferred; } From 2d784da2ee12cc5a6d89b011827cff6361a12c23 Mon Sep 17 00:00:00 2001 From: Lauri Nurmi Date: Tue, 2 Oct 2018 19:49:50 +0300 Subject: [PATCH 082/140] Load catalogs for all preferred languages, if they exist This way the first and only fallback language isn't necessarily the msgid language (which is English most often). This is how GNU gettext works -- it uses multiple fallback languages when multiple preferred languages are set. As a side effect, fixes #18227 in one possible way. --- interface/wx/translation.h | 15 +++++++++------ src/common/translation.cpp | 31 +++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/interface/wx/translation.h b/interface/wx/translation.h index a57c9930d0..fd39fd6b18 100644 --- a/interface/wx/translation.h +++ b/interface/wx/translation.h @@ -190,9 +190,10 @@ public: bool AddStdCatalog(); /** - Add a catalog for use with the current locale. + Add a catalog for the preferred UI language. In case of multiple + preferences, add catalog for each language, if available. - By default, it is searched for in standard places (see + By default, the catalog is searched for in standard places (see wxFileTranslationsLoader), but you may also prepend additional directories to the search path with wxFileTranslationsLoader::AddCatalogLookupPathPrefix(). @@ -216,8 +217,9 @@ public: code are used instead. @return - @true if catalog was successfully loaded, @false otherwise (which might - mean that the catalog is not found or that it isn't in the correct format). + @true if catalog in the most preferred language was successfully loaded, + @false otherwise (which might mean that the catalog is not found or that + it isn't in the correct format). */ bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage = wxLANGUAGE_ENGLISH_US); @@ -243,8 +245,9 @@ public: in case they use 8-bit characters (e.g. German or French strings). @return - @true if catalog was successfully loaded, @false otherwise (which might - mean that the catalog is not found or that it isn't in the correct format). + @true if catalog in the most preferred language was successfully loaded, + @false otherwise (which might mean that the catalog is not found or that + it isn't in the correct format). */ bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage, diff --git a/src/common/translation.cpp b/src/common/translation.cpp index a64327eaef..377dc533f1 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -1555,9 +1555,9 @@ bool wxTranslations::AddCatalog(const wxString& domain, wxLanguage msgIdLanguage) { const wxString msgIdLang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); - const wxString domain_lang = GetBestTranslation(domain, msgIdLang); + const wxArrayString domain_langs = GetAllGoodTranslations(domain, msgIdLanguage); - if ( domain_lang.empty() ) + if ( domain_langs.empty() ) { wxLogTrace(TRACE_I18N, wxS("no suitable translation for domain '%s' found"), @@ -1565,11 +1565,30 @@ bool wxTranslations::AddCatalog(const wxString& domain, return false; } - wxLogTrace(TRACE_I18N, - wxS("adding '%s' translation for domain '%s' (msgid language '%s')"), - domain_lang, domain, msgIdLang); + bool success = false; + for ( wxArrayString::const_iterator lang = domain_langs.begin(); + lang != domain_langs.end(); + ++lang ) + { + wxLogTrace(TRACE_I18N, + wxS("adding '%s' translation for domain '%s' (msgid language '%s')"), + *lang, domain, msgIdLang); - return LoadCatalog(domain, domain_lang, msgIdLang); + // No use loading languages that are less preferred than the + // msgid language, as by definition it contains all the strings + // in the msgid language. + if ( msgIdLang == *lang ) + break; + + // We determine success by the success of loading/failing to load + // the most preferred (i.e. the first one) language's catalog: + if ( lang == domain_langs.begin() ) + success = LoadCatalog(domain, *lang, msgIdLang); + else + LoadCatalog(domain, *lang, msgIdLang); + } + + return success; } From 20b02d6169fed3ae68caa6a12aa1003a205672f2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Nov 2018 01:43:11 +0100 Subject: [PATCH 083/140] Rename new wxTranslations method to GetAcceptableTranslations() This name seems to be more precise than a very generic "all good" one used previously. --- include/wx/translation.h | 7 +++--- interface/wx/translation.h | 45 +++++++++++++------------------------- src/common/translation.cpp | 14 ++++++------ 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/include/wx/translation.h b/include/wx/translation.h index 266166019c..9b931a088a 100644 --- a/include/wx/translation.h +++ b/include/wx/translation.h @@ -146,9 +146,10 @@ public: const wxString& msgIdLanguage = "en"); // find best and all other suitable translation languages for given domain - wxArrayString GetAllGoodTranslations(const wxString& domain, wxLanguage msgIdLanguage); - wxArrayString GetAllGoodTranslations(const wxString& domain, - const wxString& msgIdLanguage = "en"); + wxArrayString GetAcceptableTranslations(const wxString& domain, + wxLanguage msgIdLanguage); + wxArrayString GetAcceptableTranslations(const wxString& domain, + const wxString& msgIdLanguage = "en"); // add standard wxWidgets catalog ("wxstd") bool AddStdCatalog(); diff --git a/interface/wx/translation.h b/interface/wx/translation.h index fd39fd6b18..23ca5128c7 100644 --- a/interface/wx/translation.h +++ b/interface/wx/translation.h @@ -137,47 +137,32 @@ public: const wxString& msgIdLanguage = "en"); /** - Returns the best and all other suitable UI languages for the @a domain. + Returns the languages of all translations that can be used for the @a + domain. - This is nearly the same as GetBestTranslation(), but returns the - whole list of preferred UI languages for which a translation for the - @a domain was found. + This is a more general version of GetBestTranslation(), which returns + the whole list of preferred UI languages for which a translation for + the @a domain was found instead of just the first, i.e. the most + preferred, element of this list. @param domain The catalog domain to look for. @param msgIdLanguage - Specifies the language of "msgid" strings in source code - (i.e. arguments to GetString(), wxGetTranslation() and the _() macro). + Specifies the language of "msgid" strings in source code (i.e. + arguments to GetString(), wxGetTranslation() and the _() macro). - @return An array of language codes if any suitable matches were found, empty array - otherwise. + @return An array of language codes if any suitable matches were found, + empty array otherwise. @since 3.1.2 */ - wxArrayString GetAllGoodTranslations(const wxString& domain, wxLanguage msgIdLanguage); + wxArrayString GetAcceptableTranslations(const wxString& domain, + wxLanguage msgIdLanguage); - /** - Returns the best and all other suitable UI languages for the @a domain. - - This is nearly the same as GetBestTranslation(), but returns the - whole list of preferred UI languages for which a translation for the - @a domain was found. - - @param domain - The catalog domain to look for. - - @param msgIdLanguage - Specifies the language of "msgid" strings in source code - (i.e. arguments to GetString(), wxGetTranslation() and the _() macro). - - @return An array of language codes if any suitable matches were found, empty array - otherwise. - - @since 3.1.2 - */ - wxArrayString GetAllGoodTranslations(const wxString& domain, - const wxString& msgIdLanguage = "en"); + /// @overload + wxArrayString GetAcceptableTranslations(const wxString& domain, + const wxString& msgIdLanguage = "en"); /** Add standard wxWidgets catalogs ("wxstd" and possible port-specific diff --git a/src/common/translation.cpp b/src/common/translation.cpp index 377dc533f1..7d9937cd18 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -1555,7 +1555,7 @@ bool wxTranslations::AddCatalog(const wxString& domain, wxLanguage msgIdLanguage) { const wxString msgIdLang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); - const wxArrayString domain_langs = GetAllGoodTranslations(domain, msgIdLanguage); + const wxArrayString domain_langs = GetAcceptableTranslations(domain, msgIdLanguage); if ( domain_langs.empty() ) { @@ -1675,21 +1675,21 @@ wxString wxTranslations::GetBestTranslation(const wxString& domain, wxString wxTranslations::GetBestTranslation(const wxString& domain, const wxString& msgIdLanguage) { - const wxArrayString allGoodOnes = GetAllGoodTranslations(domain, msgIdLanguage); + const wxArrayString allGoodOnes = GetAcceptableTranslations(domain, msgIdLanguage); wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]); return allGoodOnes[0]; } -wxArrayString wxTranslations::GetAllGoodTranslations(const wxString& domain, - wxLanguage msgIdLanguage) +wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain, + wxLanguage msgIdLanguage) { const wxString lang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); - return GetAllGoodTranslations(domain, lang); + return GetAcceptableTranslations(domain, lang); } -wxArrayString wxTranslations::GetAllGoodTranslations(const wxString& domain, - const wxString& msgIdLanguage) +wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain, + const wxString& msgIdLanguage) { wxArrayString available(GetAvailableTranslations(domain)); // it's OK to have duplicates, so just add msgid language From c913f4a3dfabd4a8eab55a7aeef4772cd6d9651a Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 11 Nov 2018 14:44:54 +0100 Subject: [PATCH 084/140] Update mailmap --- .mailmap | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 79a840e34a..f91ded8157 100644 --- a/.mailmap +++ b/.mailmap @@ -1,34 +1,54 @@ +AliKet +Anil Kumar ARATA Mizuki +Artur Sochirca Artur Wieczorek Daniel Kulp Blake Eryx Bogdan Iordanescu Cătălin Răceanu -Danny Scott + +Danny Scott + Dimitri Schoolwerth +Hashir Ahmad Frédéric Bron Hubert Talbot +Igor Korot Ilya Bizyaev +Jens Göpfert John Roberts Jouk Jansen +Jose Lorenzo Julian Smart Jevgenijs Protopopovs Hartwig Wiesmann Kinaou Hervé +Kolya Kosenko +Lauri Nurmi Lynn C. Rees Maarten Bent Manuel Martin -Martin Ettl Martin Ettl +Martin Ettl +Martin Ettl +Mathew Maidment Micha Ahrweiler ousnius Paul Cornett Paul Kulchenko +Pavel O. +Pavel O. +Pavel Tyunin <36256989+pavel-t@users.noreply.github.com> PB +Prashant Kumar Nirmal +René Kijewski Richard Fath +Richard Powell +Roberto Boriotti Steve Browne Tim Kosse @@ -41,4 +61,6 @@ Václav Slavík Václav Slavík Vadim Zeitlin +Wolfgang Stöggl Xlord2 +Iwbnwif Yiw From bdca91c629c752bb733490dbb317c590646c4120 Mon Sep 17 00:00:00 2001 From: imReker Date: Mon, 12 Nov 2018 17:18:28 +0800 Subject: [PATCH 085/140] Fix i18n URL parsing problem in wxWebViewArchiveHandler URL is encoded as UTF-8, so using c_str() may generate invalid encoded representation in non-UTF-8 locales. Closes https://github.com/wxWidgets/wxWidgets/pull/1022 --- src/common/webviewarchivehandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/webviewarchivehandler.cpp b/src/common/webviewarchivehandler.cpp index 963c7fd210..509bacd3c2 100644 --- a/src/common/webviewarchivehandler.cpp +++ b/src/common/webviewarchivehandler.cpp @@ -85,7 +85,7 @@ wxFSFile* wxWebViewArchiveHandler::GetFile(const wxString &uri) return NULL; wxString fspath = "file:" + - EscapeFileNameCharsInURL(path.substr(doubleslash + 2).c_str()); + EscapeFileNameCharsInURL(path.substr(doubleslash + 2).utf8_str()); return m_fileSystem->OpenFile(fspath); } //Otherwise we need to extract the protocol @@ -108,7 +108,7 @@ wxFSFile* wxWebViewArchiveHandler::GetFile(const wxString &uri) return NULL; wxString fspath = "file:" + - EscapeFileNameCharsInURL(mainpath.substr(doubleslash + 2).c_str()) + EscapeFileNameCharsInURL(mainpath.substr(doubleslash + 2).utf8_str()) + "#" + protocol +":" + archivepath; return m_fileSystem->OpenFile(fspath); } From cb8b6009d590ae9c72d97fc6fb1abb538638dc34 Mon Sep 17 00:00:00 2001 From: Markus Juergens Date: Sun, 18 Nov 2018 20:49:34 +0100 Subject: [PATCH 086/140] Add a size selection choice to the "artprov" sample This will allow to test support for larger icons when it is added in the upcoming commits. --- samples/artprov/artbrows.cpp | 45 ++++++++++++++++++++++++++++++++---- samples/artprov/artbrows.h | 7 ++++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/samples/artprov/artbrows.cpp b/samples/artprov/artbrows.cpp index 93e0f9f638..8cefcd5e19 100644 --- a/samples/artprov/artbrows.cpp +++ b/samples/artprov/artbrows.cpp @@ -126,8 +126,13 @@ static void FillBitmaps(wxImageList *images, wxListCtrl *list, #include "null.xpm" +const int SIZE_CHOICE_ID = ::wxNewId(); + +int wxArtBrowserDialog::m_bitmap_sizes[] = { -1, 16, 32, 64, 128, 256, 0 }; + wxBEGIN_EVENT_TABLE(wxArtBrowserDialog, wxDialog) EVT_LIST_ITEM_SELECTED(wxID_ANY, wxArtBrowserDialog::OnSelectItem) + EVT_CHOICE(SIZE_CHOICE_ID, wxArtBrowserDialog::OnChangeSize) EVT_CHOICE(wxID_ANY, wxArtBrowserDialog::OnChooseClient) wxEND_EVENT_TABLE() @@ -136,6 +141,8 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) { + m_current_artid = wxART_ERROR; + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxSizer *subsizer; @@ -152,16 +159,31 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) m_list = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(250, 300), wxLC_REPORT | wxSUNKEN_BORDER); m_list->AppendColumn("wxArtID"); - subsizer->Add(m_list, 1, wxEXPAND | wxRIGHT, 10); + subsizer->Add(m_list, 0, wxEXPAND | wxRIGHT, 10); wxSizer *subsub = new wxBoxSizer(wxVERTICAL); + + m_sizes = new wxChoice( this, SIZE_CHOICE_ID ); + int size_index = 0; + while( m_bitmap_sizes[size_index] != 0 ) + { + if( m_bitmap_sizes[size_index] == -1 ) + m_sizes->Append( "Default" ); + else + m_sizes->Append( wxString::Format("%d x %d", m_bitmap_sizes[size_index], m_bitmap_sizes[size_index] ) ); + + size_index++; + } + m_sizes->SetSelection(0); + subsub->Add(m_sizes, 0, wxALL, 4); + m_text = new wxStaticText(this, wxID_ANY, "Size: 333x333"); - subsub->Add(m_text); + subsub->Add(m_text, 0, wxALL, 4); m_canvas = new wxStaticBitmap(this, wxID_ANY, wxBitmap(null_xpm)); subsub->Add(m_canvas); - subsub->Add(100, 100); - subsizer->Add(subsub); + subsub->Add(256, 256); + subsizer->Add(subsub, 1, wxLEFT, 4 ); sizer->Add(subsizer, 1, wxEXPAND | wxLEFT|wxRIGHT, 10); @@ -176,6 +198,13 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) } +wxSize wxArtBrowserDialog::GetSelectedBitmapSize() const +{ + int size = m_bitmap_sizes[ m_sizes->GetSelection() ]; + return wxSize( size, size ); +} + + void wxArtBrowserDialog::SetArtClient(const wxArtClient& client) { wxBusyCursor bcur; @@ -201,7 +230,13 @@ void wxArtBrowserDialog::SetArtClient(const wxArtClient& client) void wxArtBrowserDialog::OnSelectItem(wxListEvent &event) { const char *data = (const char*)event.GetData(); - SetArtBitmap(data, m_client, wxDefaultSize); + m_current_artid = wxString( data ); + SetArtBitmap(data, m_client, GetSelectedBitmapSize()); +} + +void wxArtBrowserDialog::OnChangeSize(wxCommandEvent &event) +{ + SetArtBitmap(m_current_artid, m_client, GetSelectedBitmapSize() ); } void wxArtBrowserDialog::OnChooseClient(wxCommandEvent &event) diff --git a/samples/artprov/artbrows.h b/samples/artprov/artbrows.h index 977dce30f3..4c794834b1 100644 --- a/samples/artprov/artbrows.h +++ b/samples/artprov/artbrows.h @@ -28,12 +28,19 @@ public: private: void OnSelectItem(wxListEvent &event); + void OnChangeSize(wxCommandEvent &event); void OnChooseClient(wxCommandEvent &event); + wxSize GetSelectedBitmapSize() const; + wxListCtrl *m_list; wxStaticBitmap *m_canvas; wxStaticText *m_text; wxString m_client; + wxChoice *m_sizes; + wxString m_current_artid; + + static int m_bitmap_sizes[7]; wxDECLARE_EVENT_TABLE(); }; From 303fa4b3ef632a5a9e887c416d56028a90b2c643 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Nov 2018 20:55:09 +0100 Subject: [PATCH 087/140] Minor cleanup in the "artprov" sample after the previous commit Use the standard wxWidgets camelCase naming convention instead of snake_case and fix some style inconsistencies. No real changes. --- samples/artprov/artbrows.cpp | 24 +++++++++++------------- samples/artprov/artbrows.h | 4 +--- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/samples/artprov/artbrows.cpp b/samples/artprov/artbrows.cpp index 8cefcd5e19..ea0b9944da 100644 --- a/samples/artprov/artbrows.cpp +++ b/samples/artprov/artbrows.cpp @@ -128,7 +128,8 @@ static void FillBitmaps(wxImageList *images, wxListCtrl *list, const int SIZE_CHOICE_ID = ::wxNewId(); -int wxArtBrowserDialog::m_bitmap_sizes[] = { -1, 16, 32, 64, 128, 256, 0 }; +// Bitmap sizes that can be chosen in the size selection wxChoice. +static const int bitmapSizes[] = { -1, 16, 32, 64, 128, 256, 0 }; wxBEGIN_EVENT_TABLE(wxArtBrowserDialog, wxDialog) EVT_LIST_ITEM_SELECTED(wxID_ANY, wxArtBrowserDialog::OnSelectItem) @@ -141,7 +142,7 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) { - m_current_artid = wxART_ERROR; + m_currentArtId = wxART_ERROR; wxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxSizer *subsizer; @@ -164,15 +165,12 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) wxSizer *subsub = new wxBoxSizer(wxVERTICAL); m_sizes = new wxChoice( this, SIZE_CHOICE_ID ); - int size_index = 0; - while( m_bitmap_sizes[size_index] != 0 ) + for ( const int* p = bitmapSizes; *p; ++p ) { - if( m_bitmap_sizes[size_index] == -1 ) + if ( *p == -1 ) m_sizes->Append( "Default" ); else - m_sizes->Append( wxString::Format("%d x %d", m_bitmap_sizes[size_index], m_bitmap_sizes[size_index] ) ); - - size_index++; + m_sizes->Append( wxString::Format("%d x %d", *p, *p ) ); } m_sizes->SetSelection(0); subsub->Add(m_sizes, 0, wxALL, 4); @@ -200,8 +198,8 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) wxSize wxArtBrowserDialog::GetSelectedBitmapSize() const { - int size = m_bitmap_sizes[ m_sizes->GetSelection() ]; - return wxSize( size, size ); + const int size = bitmapSizes[m_sizes->GetSelection()]; + return wxSize(size, size); } @@ -230,13 +228,13 @@ void wxArtBrowserDialog::SetArtClient(const wxArtClient& client) void wxArtBrowserDialog::OnSelectItem(wxListEvent &event) { const char *data = (const char*)event.GetData(); - m_current_artid = wxString( data ); + m_currentArtId = wxString( data ); SetArtBitmap(data, m_client, GetSelectedBitmapSize()); } -void wxArtBrowserDialog::OnChangeSize(wxCommandEvent &event) +void wxArtBrowserDialog::OnChangeSize(wxCommandEvent& WXUNUSED(event)) { - SetArtBitmap(m_current_artid, m_client, GetSelectedBitmapSize() ); + SetArtBitmap(m_currentArtId, m_client, GetSelectedBitmapSize() ); } void wxArtBrowserDialog::OnChooseClient(wxCommandEvent &event) diff --git a/samples/artprov/artbrows.h b/samples/artprov/artbrows.h index 4c794834b1..e1dbb093b5 100644 --- a/samples/artprov/artbrows.h +++ b/samples/artprov/artbrows.h @@ -38,9 +38,7 @@ private: wxStaticText *m_text; wxString m_client; wxChoice *m_sizes; - wxString m_current_artid; - - static int m_bitmap_sizes[7]; + wxString m_currentArtId; wxDECLARE_EVENT_TABLE(); }; From d5cd939db73854469f7ff8e0d699f15fea6ec8db Mon Sep 17 00:00:00 2001 From: Markus Juergens Date: Sun, 18 Nov 2018 20:58:57 +0100 Subject: [PATCH 088/140] Use native art for PRINT and XXX_FILE art IDs under MSW These art IDs have natural native equivalents, so do use them. --- src/msw/artmsw.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index eb7a6c4ec8..8c4c5612b0 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -51,6 +51,9 @@ SHSTOCKICONID MSWGetStockIconIdForArtProviderId(const wxArtID& art_id) else if ( art_id == wxART_FLOPPY ) return SIID_DRIVE35; else if ( art_id == wxART_CDROM ) return SIID_DRIVECD; else if ( art_id == wxART_REMOVABLE ) return SIID_DRIVEREMOVE; + else if ( art_id == wxART_PRINT ) return SIID_PRINTER; + else if ( art_id == wxART_EXECUTABLE_FILE ) return SIID_APPLICATION; + else if ( art_id == wxART_NORMAL_FILE ) return SIID_DOCNOASSOC; return SIID_INVALID; }; From 880b2b0a460cd0c52838910683d53fdfedf211c0 Mon Sep 17 00:00:00 2001 From: Markus Juergens Date: Sun, 18 Nov 2018 21:16:00 +0100 Subject: [PATCH 089/140] Use icons of correct sizes for wxART_FOLDER in wxMSW Don't restrict the sizes to just small or large icons but extract the icon closest to the requested size using SHDefExtractIcon(). --- src/msw/artmsw.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 8c4c5612b0..329dfbd7b7 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -25,6 +25,7 @@ #include "wx/volume.h" #include "wx/msw/private.h" #include "wx/msw/wrapwin.h" +#include "wx/msw/wrapshl.h" #ifdef SHGSI_ICON #define wxHAS_SHGetStockIconInfo @@ -90,24 +91,22 @@ MSWGetBitmapForPath(const wxString& path, const wxSize& size, DWORD uFlags = 0) SHFILEINFO fi; wxZeroMemory(fi); - uFlags |= SHGFI_USEFILEATTRIBUTES | SHGFI_ICON; - if ( size != wxDefaultSize ) - { - if ( size.x <= 16 ) - uFlags |= SHGFI_SMALLICON; - else if ( size.x >= 64 ) - uFlags |= SHGFI_LARGEICON; - } + uFlags |= SHGFI_USEFILEATTRIBUTES | SHGFI_ICONLOCATION; if ( !SHGetFileInfo(path.t_str(), FILE_ATTRIBUTE_DIRECTORY, &fi, sizeof(SHFILEINFO), uFlags) ) + return wxNullBitmap; + + HICON hIcon = NULL; + if ( !SHDefExtractIcon(fi.szDisplayName, fi.iIcon, 0, + &hIcon, NULL, size.x) ) return wxNullBitmap; wxIcon icon; - icon.CreateFromHICON((WXHICON)fi.hIcon); + icon.CreateFromHICON((WXHICON)hIcon); wxBitmap bitmap(icon); - ::DestroyIcon(fi.hIcon); + ::DestroyIcon(hIcon); return bitmap; } From 8698d69c77b37aded54a6f8b69b6184abf2a5813 Mon Sep 17 00:00:00 2001 From: Markus Juergens Date: Sun, 18 Nov 2018 22:34:40 +0100 Subject: [PATCH 090/140] Return the best-sized icons from wxWindowsArtProvider Use SHDefExtractIcon() to retrieve the most appropriately-sized icon instead of always getting either the small or the large icon and then scaling it ourselves to make it of the right size. This results in incomparably better results for large icon sizes, e.g. 256*256, as can be seen in the artprov sample. --- src/msw/artmsw.cpp | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 329dfbd7b7..afc90823a9 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -180,38 +180,37 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id, { WinStruct sii; - UINT uFlags = SHGSI_ICON; - if ( size != wxDefaultSize ) - { - if ( size.x <= 16 ) - uFlags |= SHGSI_SMALLICON; - else if ( size.x >= 64 ) - uFlags |= SHGSI_LARGEICON; - } + UINT uFlags = SHGSI_ICONLOCATION | SHGSI_SYSICONINDEX; HRESULT res = MSW_SHGetStockIconInfo(stockIconId, uFlags, &sii); if ( res == S_OK ) { - wxIcon icon; - icon.CreateFromHICON( (WXHICON)sii.hIcon ); + const wxSize + sizeNeeded = size.IsFullySpecified() + ? size + : wxArtProvider::GetNativeSizeHint(client); - bitmap = wxBitmap(icon); - ::DestroyIcon(sii.hIcon); - - if ( bitmap.IsOk() ) + HICON hIcon = NULL; + res = SHDefExtractIcon(sii.szPath, sii.iIcon, 0, + &hIcon, NULL, sizeNeeded.x); + if ( res == S_OK ) { - const wxSize - sizeNeeded = size.IsFullySpecified() - ? size - : wxArtProvider::GetNativeSizeHint(client); + wxIcon icon; + icon.CreateFromHICON((WXHICON)hIcon); - if ( sizeNeeded.IsFullySpecified() && - bitmap.GetSize() != sizeNeeded ) + bitmap = wxBitmap(icon); + ::DestroyIcon(hIcon); + + if ( bitmap.IsOk() ) { - wxArtProvider::RescaleBitmap(bitmap, sizeNeeded); - } + if ( sizeNeeded.IsFullySpecified() && + bitmap.GetSize() != sizeNeeded ) + { + wxArtProvider::RescaleBitmap(bitmap, sizeNeeded); + } - return bitmap; + return bitmap; + } } } } From 49d8491518e7110512060044886c25dc442f1569 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Nov 2018 22:43:17 +0100 Subject: [PATCH 091/140] Refactor the code to use a wrapper for SHDefExtractIcon() Avoid duplicating the same code in MSWGetBitmapForPath() and CreateBitmap(). This also incidentally fixes SHDefExtractIcon() return value check, which was inverted, in MSWGetBitmapForPath(). --- src/msw/artmsw.cpp | 56 +++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index afc90823a9..4d5c03b6ce 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -85,6 +85,23 @@ MSW_SHGetStockIconInfo(SHSTOCKICONID siid, #endif // #ifdef wxHAS_SHGetStockIconInfo +// Wrapper for SHDefExtractIcon(). +wxBitmap +MSWGetBitmapFromIconLocation(const TCHAR* path, int index, const wxSize& size) +{ + HICON hIcon = NULL; + if ( SHDefExtractIcon(path, index, 0, &hIcon, NULL, size.x) != S_OK ) + return wxNullBitmap; + + wxIcon icon; + icon.CreateFromHICON((WXHICON)hIcon); + + wxBitmap bitmap(icon); + ::DestroyIcon(hIcon); + + return bitmap; +} + wxBitmap MSWGetBitmapForPath(const wxString& path, const wxSize& size, DWORD uFlags = 0) { @@ -97,18 +114,7 @@ MSWGetBitmapForPath(const wxString& path, const wxSize& size, DWORD uFlags = 0) &fi, sizeof(SHFILEINFO), uFlags) ) return wxNullBitmap; - HICON hIcon = NULL; - if ( !SHDefExtractIcon(fi.szDisplayName, fi.iIcon, 0, - &hIcon, NULL, size.x) ) - return wxNullBitmap; - - wxIcon icon; - icon.CreateFromHICON((WXHICON)hIcon); - - wxBitmap bitmap(icon); - ::DestroyIcon(hIcon); - - return bitmap; + return MSWGetBitmapFromIconLocation(fi.szDisplayName, fi.iIcon, size); } #if wxUSE_FSVOLUME @@ -190,27 +196,17 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id, ? size : wxArtProvider::GetNativeSizeHint(client); - HICON hIcon = NULL; - res = SHDefExtractIcon(sii.szPath, sii.iIcon, 0, - &hIcon, NULL, sizeNeeded.x); - if ( res == S_OK ) + bitmap = MSWGetBitmapFromIconLocation(sii.szPath, sii.iIcon, + sizeNeeded); + if ( bitmap.IsOk() ) { - wxIcon icon; - icon.CreateFromHICON((WXHICON)hIcon); - - bitmap = wxBitmap(icon); - ::DestroyIcon(hIcon); - - if ( bitmap.IsOk() ) + if ( sizeNeeded.IsFullySpecified() && + bitmap.GetSize() != sizeNeeded ) { - if ( sizeNeeded.IsFullySpecified() && - bitmap.GetSize() != sizeNeeded ) - { - wxArtProvider::RescaleBitmap(bitmap, sizeNeeded); - } - - return bitmap; + wxArtProvider::RescaleBitmap(bitmap, sizeNeeded); } + + return bitmap; } } } From 262124ca1b13bc4f0c3caa58bc2948804696838c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Nov 2018 22:47:29 +0100 Subject: [PATCH 092/140] Remove unnecessary bitmap size check in wxWindowsArtProvider This "sizeNeeded" is always fully specified as we explicitly use a fallback size if the input size wasn't, so there is no need for checking this. --- src/msw/artmsw.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 4d5c03b6ce..730b5127cd 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -200,8 +200,7 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id, sizeNeeded); if ( bitmap.IsOk() ) { - if ( sizeNeeded.IsFullySpecified() && - bitmap.GetSize() != sizeNeeded ) + if ( bitmap.GetSize() != sizeNeeded ) { wxArtProvider::RescaleBitmap(bitmap, sizeNeeded); } From 8e740c69cdfe7717a7435cea8a365d839f106fb9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Nov 2018 23:09:01 +0100 Subject: [PATCH 093/140] Initialize icon using InitFromHICON() instead of CreateFromHICON() The former avoids an unnecessary call to ::GetIconInfo() done by the latter to retrieve the icon size, as we already have the size here. --- src/msw/artmsw.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 730b5127cd..2fea3339e9 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -93,8 +93,13 @@ MSWGetBitmapFromIconLocation(const TCHAR* path, int index, const wxSize& size) if ( SHDefExtractIcon(path, index, 0, &hIcon, NULL, size.x) != S_OK ) return wxNullBitmap; + // Note that using "size.x" twice here is not a typo: normally size.y is + // the same anyhow, of course, but if it isn't, the actual icon size would + // be size.x in both directions as we only pass "x" to SHDefExtractIcon() + // above. wxIcon icon; - icon.CreateFromHICON((WXHICON)hIcon); + if ( !icon.InitFromHICON((WXHICON)hIcon, size.x, size.x) ) + return wxNullBitmap; wxBitmap bitmap(icon); ::DestroyIcon(hIcon); From 3169524864cab5178cf1106222e64170c866f16d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Nov 2018 23:10:07 +0100 Subject: [PATCH 094/140] Don't destroy the HICON returned by SHDefExtractIcon() twice Surprisingly, this doesn't seem to result in any ill effects, but passing HICON to wxIcon already ensures that this HICON will be destroyed in wxIcon dtor, so we shouldn't call ::DestroyIcon() on it manually. --- src/msw/artmsw.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 2fea3339e9..0d49683846 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -101,10 +101,7 @@ MSWGetBitmapFromIconLocation(const TCHAR* path, int index, const wxSize& size) if ( !icon.InitFromHICON((WXHICON)hIcon, size.x, size.x) ) return wxNullBitmap; - wxBitmap bitmap(icon); - ::DestroyIcon(hIcon); - - return bitmap; + return wxBitmap(icon); } wxBitmap From f790ccee6ff6f261a307caa10252a68e954a2349 Mon Sep 17 00:00:00 2001 From: oneeyeman1 Date: Sun, 18 Nov 2018 23:19:45 -0500 Subject: [PATCH 095/140] Implement Password style for text control under wxQt --- src/qt/textctrl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/textctrl.cpp b/src/qt/textctrl.cpp index c600216903..d9069b9b60 100644 --- a/src/qt/textctrl.cpp +++ b/src/qt/textctrl.cpp @@ -121,6 +121,8 @@ bool wxTextCtrl::Create(wxWindow *parent, { m_qtLineEdit = new wxQtLineEdit( parent, this ); m_qtTextEdit = NULL; + if( style & wxTE_PASSWORD ) + m_qtLineEdit->setEchoMode( QLineEdit::Password ); } else { From a245c0af1e4b5ea7faa48521b701e295c8381ce5 Mon Sep 17 00:00:00 2001 From: oneeyeman1 Date: Sun, 18 Nov 2018 23:40:05 -0500 Subject: [PATCH 096/140] Implement modification flag on text control for wxQt --- src/qt/textctrl.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/qt/textctrl.cpp b/src/qt/textctrl.cpp index d9069b9b60..60baa4c719 100644 --- a/src/qt/textctrl.cpp +++ b/src/qt/textctrl.cpp @@ -163,15 +163,26 @@ int wxTextCtrl::GetNumberOfLines() const bool wxTextCtrl::IsModified() const { - return false; + if( !IsMultiLine() ) + return m_qtLineEdit->isModified(); + else + return m_qtTextEdit->isWindowModified(); } void wxTextCtrl::MarkDirty() { + if( !IsMultiLine() ) + return m_qtLineEdit->setModified( true ); + else + return m_qtTextEdit->setWindowModified( true ); } void wxTextCtrl::DiscardEdits() { + if( !IsMultiLine() ) + return m_qtLineEdit->setModified( false ); + else + return m_qtTextEdit->setWindowModified( false ); } bool wxTextCtrl::SetStyle(long WXUNUSED(start), long WXUNUSED(end), const wxTextAttr& WXUNUSED(style)) From 99247910b940e4f47728c3c73984c393d1dd48d5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Nov 2018 16:12:14 +0100 Subject: [PATCH 097/140] Declare SHDefExtractIcon() if it's missing from (MinGW) headers At least the MinGW 5.3 used for AppVeyor builds doesn't declare this function, so provide its declaration ourselves to fix MinGW build after the recent changes. --- src/msw/artmsw.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 0d49683846..514912d86e 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -31,6 +31,27 @@ #define wxHAS_SHGetStockIconInfo #endif +// MinGW headers don't always define this symbol (up to at least 5.3 version), +// so do it ourselves. +// +// Note that at least there is no need for run-time loading here, as it's +// available since XP. +#ifndef SHDefExtractIcon + +#ifdef UNICODE +extern "C" HRESULT wxSTDCALL +SHDefExtractIconW(LPCWSTR pszIconFile, int iIndex, UINT uFlags, + HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize); +#define SHDefExtractIcon SHDefExtractIconW +#else // !UNICODE +extern "C" HRESULT wxSTDCALL +SHDefExtractIconA(LPCSTR pszIconFile, int iIndex, UINT uFlags, + HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize); +#define SHDefExtractIcon SHDefExtractIconA +#endif // UNICODE/!UNICODE + +#endif // !defined(SHDefExtractIcon) + namespace { From 0308596e924970a384116b838fc21d44e287968c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Nov 2018 16:17:05 +0100 Subject: [PATCH 098/140] Use real email address for Markus Juergens See #18248. --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index f91ded8157..122cdf3c75 100644 --- a/.mailmap +++ b/.mailmap @@ -31,6 +31,7 @@ Lauri Nurmi Lynn C. Rees Maarten Bent Manuel Martin +Markus Juergens Martin Ettl Martin Ettl Martin Ettl From add8e8804b41045c297a5e85de711abe2beb002c Mon Sep 17 00:00:00 2001 From: oneeyeman1 Date: Tue, 20 Nov 2018 05:51:29 -0500 Subject: [PATCH 099/140] Follow up with the PR comments --- src/qt/textctrl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/textctrl.cpp b/src/qt/textctrl.cpp index 60baa4c719..5ef1bd97ff 100644 --- a/src/qt/textctrl.cpp +++ b/src/qt/textctrl.cpp @@ -121,7 +121,7 @@ bool wxTextCtrl::Create(wxWindow *parent, { m_qtLineEdit = new wxQtLineEdit( parent, this ); m_qtTextEdit = NULL; - if( style & wxTE_PASSWORD ) + if ( style & wxTE_PASSWORD ) m_qtLineEdit->setEchoMode( QLineEdit::Password ); } else @@ -163,7 +163,7 @@ int wxTextCtrl::GetNumberOfLines() const bool wxTextCtrl::IsModified() const { - if( !IsMultiLine() ) + if ( IsSingleLine() ) return m_qtLineEdit->isModified(); else return m_qtTextEdit->isWindowModified(); @@ -171,7 +171,7 @@ bool wxTextCtrl::IsModified() const void wxTextCtrl::MarkDirty() { - if( !IsMultiLine() ) + if ( IsSingleLine() ) return m_qtLineEdit->setModified( true ); else return m_qtTextEdit->setWindowModified( true ); @@ -179,7 +179,7 @@ void wxTextCtrl::MarkDirty() void wxTextCtrl::DiscardEdits() { - if( !IsMultiLine() ) + if ( IsSingleLine() ) return m_qtLineEdit->setModified( false ); else return m_qtTextEdit->setWindowModified( false ); From f7514dc79d5ad2f3e2f4a89b6d834e14fddb4b8b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 20 Nov 2018 14:11:53 +0100 Subject: [PATCH 100/140] Suppress harmless gcc -Wfloat-equal in wxNumValidator code Exact comparison with 0 here is fine, so just disable the warning for this code. Closes #18271. --- include/wx/valnum.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/wx/valnum.h b/include/wx/valnum.h index 3f9be1d99c..2e05bc6b15 100644 --- a/include/wx/valnum.h +++ b/include/wx/valnum.h @@ -228,10 +228,16 @@ private: // wxNUM_VAL_ZERO_AS_BLANK flag. wxString NormalizeValue(LongestValueType value) const { + // We really want to compare with the exact 0 here, so disable gcc + // warning about doing this. + wxGCC_WARNING_SUPPRESS(float-equal) + wxString s; if ( value != 0 || !BaseValidator::HasFlag(wxNUM_VAL_ZERO_AS_BLANK) ) s = this->ToString(value); + wxGCC_WARNING_RESTORE(float-equal) + return s; } From ea28f00cb817cf1fc557f80bae5270be18118d6c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 20 Nov 2018 15:29:43 +0100 Subject: [PATCH 101/140] Do load SHDefExtractIcon() during run-time for old MinGW The problem with MinGW 5.3 is not just due to the missing function declaration in the header, but also due to the function missing from libshell32.a import library, so we do need to load it during run-time, contrary to what the comment in the previous commit said. This should finally fix MinGW build. --- src/msw/artmsw.cpp | 56 ++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 514912d86e..1d836fd56e 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -31,30 +31,42 @@ #define wxHAS_SHGetStockIconInfo #endif -// MinGW headers don't always define this symbol (up to at least 5.3 version), -// so do it ourselves. -// -// Note that at least there is no need for run-time loading here, as it's -// available since XP. -#ifndef SHDefExtractIcon - -#ifdef UNICODE -extern "C" HRESULT wxSTDCALL -SHDefExtractIconW(LPCWSTR pszIconFile, int iIndex, UINT uFlags, - HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize); -#define SHDefExtractIcon SHDefExtractIconW -#else // !UNICODE -extern "C" HRESULT wxSTDCALL -SHDefExtractIconA(LPCSTR pszIconFile, int iIndex, UINT uFlags, - HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize); -#define SHDefExtractIcon SHDefExtractIconA -#endif // UNICODE/!UNICODE - -#endif // !defined(SHDefExtractIcon) - namespace { +#ifdef SHDefExtractIcon + #define MSW_SHDefExtractIcon SHDefExtractIcon +#else // !defined(SHDefExtractIcon) + +// MinGW doesn't provide SHDefExtractIcon() up to at least the 5.3 version, so +// define it ourselves. +HRESULT +MSW_SHDefExtractIcon(LPCTSTR pszIconFile, int iIndex, UINT uFlags, + HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) +{ + typedef HRESULT + (WINAPI *SHDefExtractIcon_t)(LPCTSTR, int, UINT, HICON*, HICON*, UINT); + + static SHDefExtractIcon_t s_SHDefExtractIcon = NULL; + if ( !s_SHDefExtractIcon ) + { + wxDynamicLibrary shell32(wxT("shell32.dll")); + wxDL_INIT_FUNC_AW(s_, SHDefExtractIcon, shell32); + + if ( !s_SHDefExtractIcon ) + return E_FAIL; + + // Prevent the DLL from being unloaded while we use its function. + // Normally it's not a problem as shell32.dll is always loaded anyhow. + shell32.Detach(); + } + + return (*s_SHDefExtractIcon)(pszIconFile, iIndex, uFlags, + phiconLarge, phiconSmall, nIconSize); +} + +#endif // !defined(SHDefExtractIcon) + #ifdef wxHAS_SHGetStockIconInfo SHSTOCKICONID MSWGetStockIconIdForArtProviderId(const wxArtID& art_id) @@ -111,7 +123,7 @@ wxBitmap MSWGetBitmapFromIconLocation(const TCHAR* path, int index, const wxSize& size) { HICON hIcon = NULL; - if ( SHDefExtractIcon(path, index, 0, &hIcon, NULL, size.x) != S_OK ) + if ( MSW_SHDefExtractIcon(path, index, 0, &hIcon, NULL, size.x) != S_OK ) return wxNullBitmap; // Note that using "size.x" twice here is not a typo: normally size.y is From 1c06a62830f5fe3a19a5ecf92cbf58f6c53d6632 Mon Sep 17 00:00:00 2001 From: oneeyeman1 Date: Thu, 1 Nov 2018 04:30:41 -0400 Subject: [PATCH 102/140] Implement dropdown and popup events for wxComboBox on Qt Closes https://github.com/wxWidgets/wxWidgets/pull/1005 --- src/qt/combobox.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/qt/combobox.cpp b/src/qt/combobox.cpp index 14af9eb2d9..1080721625 100644 --- a/src/qt/combobox.cpp +++ b/src/qt/combobox.cpp @@ -20,6 +20,8 @@ class wxQtComboBox : public wxQtEventSignalHandler< QComboBox, wxComboBox > { public: wxQtComboBox( wxWindow *parent, wxComboBox *handler ); + virtual void showPopup() wxOVERRIDE; + virtual void hidePopup() wxOVERRIDE; private: void activated(int index); @@ -36,6 +38,20 @@ wxQtComboBox::wxQtComboBox( wxWindow *parent, wxComboBox *handler ) this, &wxQtComboBox::editTextChanged); } +void wxQtComboBox::showPopup() +{ + wxCommandEvent event( wxEVT_COMBOBOX_DROPDOWN, GetHandler()->GetId() ); + EmitEvent( event ); + QComboBox::showPopup(); +} + +void wxQtComboBox::hidePopup() +{ + wxCommandEvent event( wxEVT_COMBOBOX_CLOSEUP, GetHandler()->GetId() ); + EmitEvent( event ); + QComboBox::hidePopup(); +} + void wxQtComboBox::activated(int WXUNUSED(index)) { wxComboBox *handler = GetHandler(); From f71e8d077f63b6812fab70919f33ab45e346ae30 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Tue, 20 Nov 2018 21:11:56 +0100 Subject: [PATCH 103/140] Show read-only and not read-only wxODComboBox and wxComboBox in the sample Extend the sample to compare disabled read-only and disabled not read-only combo boxes. See #3383. --- samples/combo/combo.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/samples/combo/combo.cpp b/samples/combo/combo.cpp index c489504194..fded5d1a18 100644 --- a/samples/combo/combo.cpp +++ b/samples/combo/combo.cpp @@ -1017,14 +1017,14 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->AddStretchSpacer(); // - // Disabled ODComboBox - groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Disabled:"), + // Disabled read-only ODComboBox + groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Read-only disabled:"), wxSizerFlags().Border(wxRIGHT, border) ); odc = new wxOwnerDrawnComboBox(dlg,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, - wxCB_SORT|wxCB_READONLY // wxNO_BORDER|wxCB_READONLY + wxCB_READONLY // wxNO_BORDER|wxCB_READONLY ); odc->SetValue("Dot Dash"); @@ -1032,6 +1032,18 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->Add( odc, wxSizerFlags(3).Expand().Border(wxALL, border) ); + // Disabled ODComboBox + groupSizer->Add(new wxStaticText(dlg, wxID_ANY, "Disabled:"), + wxSizerFlags().Border(wxRIGHT, border)); + + odc = new wxOwnerDrawnComboBox(dlg, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, m_arrItems); + + odc->SetValue("Dot Dash"); + odc->Enable(false); + + groupSizer->Add(odc, wxSizerFlags(3).Expand().Border(wxALL, border)); + rowSizer->Add( groupSizer, 1, wxEXPAND|wxALL, border ); @@ -1077,14 +1089,14 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->AddStretchSpacer(); // - // Disabled wxComboBox - groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Disabled:"), + // Disabled read-only wxComboBox + groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Read-only disabled:"), wxSizerFlags().Border(wxRIGHT, border) ); cb = new wxComboBox(dlg,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, - wxCB_SORT|wxCB_READONLY // wxNO_BORDER|wxCB_READONLY + wxCB_READONLY // wxNO_BORDER|wxCB_READONLY ); cb->SetValue("Dot Dash"); @@ -1092,6 +1104,19 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->Add( cb, wxSizerFlags(3).Expand().Border(wxALL, border) ); + // + // Disabled wxComboBox + groupSizer->Add(new wxStaticText(dlg, wxID_ANY, "Disabled:"), + wxSizerFlags().Border(wxRIGHT, border)); + + cb = new wxComboBox(dlg, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, m_arrItems); + + cb->SetValue("Dot Dash"); + cb->Enable(false); + + groupSizer->Add(cb, wxSizerFlags(3).Expand().Border(wxALL, border)); + rowSizer->Add( groupSizer, 1, wxEXPAND|wxALL, border ); colSizer->Add( rowSizer, 1, wxEXPAND|wxALL, border ); From c9318f2f640e0e740c0edd0976fe33b48bb610ec Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 20 Nov 2018 20:31:35 +0100 Subject: [PATCH 104/140] Update vcxproj files with new tiff files Closes https://github.com/wxWidgets/wxWidgets/pull/1028 --- build/msw/wx_wxtiff.vcxproj | 5 +++++ build/msw/wx_wxtiff.vcxproj.filters | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/build/msw/wx_wxtiff.vcxproj b/build/msw/wx_wxtiff.vcxproj index 68ba078db1..a4a9ce61ce 100644 --- a/build/msw/wx_wxtiff.vcxproj +++ b/build/msw/wx_wxtiff.vcxproj @@ -418,8 +418,11 @@ + + + @@ -435,9 +438,11 @@ + + diff --git a/build/msw/wx_wxtiff.vcxproj.filters b/build/msw/wx_wxtiff.vcxproj.filters index 9294e7c179..c45fe2cbe1 100644 --- a/build/msw/wx_wxtiff.vcxproj.filters +++ b/build/msw/wx_wxtiff.vcxproj.filters @@ -115,5 +115,20 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file From ae1fa08188190aec49a1a04765dee764e2bb0a7f Mon Sep 17 00:00:00 2001 From: Glen Fletcher Date: Wed, 21 Nov 2018 08:08:26 +1100 Subject: [PATCH 105/140] Add C++17 to the list of supported C++ Standards in CMake build Allow building with set(CMAKE_CXX_STANDARD 17). Closes https://github.com/wxWidgets/wxWidgets/pull/1029 --- build/cmake/options.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 6b03f2b068..0cf3740002 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -37,7 +37,7 @@ else() set(wxCXX_STANDARD_DEFAULT COMPILER_DEFAULT) endif() wx_option(wxBUILD_CXX_STANDARD "C++ standard used to build wxWidgets targets" - ${wxCXX_STANDARD_DEFAULT} STRINGS COMPILER_DEFAULT 98 11 14) + ${wxCXX_STANDARD_DEFAULT} STRINGS COMPILER_DEFAULT 98 11 14 17) endif() if(WIN32) From 6b7b43d1fef7e27700ca24d534cc25c0e066ea68 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 21 Nov 2018 12:58:23 +0000 Subject: [PATCH 106/140] Get WxQt menu titles passing GUI tests --- include/wx/qt/menu.h | 1 + src/qt/menu.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/wx/qt/menu.h b/include/wx/qt/menu.h index b8d5abca52..f6d52bb3e2 100644 --- a/include/wx/qt/menu.h +++ b/include/wx/qt/menu.h @@ -44,6 +44,7 @@ public: virtual wxMenu *Remove(size_t pos); virtual void EnableTop(size_t pos, bool enable); + virtual bool IsEnabledTop(size_t pos) const wxOVERRIDE; virtual void SetMenuLabel(size_t pos, const wxString& label); virtual wxString GetMenuLabel(size_t pos) const; diff --git a/src/qt/menu.cpp b/src/qt/menu.cpp index 61d27b7976..e0f7d8c5fc 100644 --- a/src/qt/menu.cpp +++ b/src/qt/menu.cpp @@ -184,6 +184,8 @@ wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], lon static QMenu *SetTitle( wxMenu *menu, const wxString &title ) { + menu->SetTitle(title); + QMenu *qtMenu = menu->GetHandle(); qtMenu->setTitle( wxQtConvertString( title )); @@ -243,6 +245,12 @@ void wxMenuBar::EnableTop(size_t pos, bool enable) qtAction->setEnabled( enable ); } +bool wxMenuBar::IsEnabledTop(size_t pos) const +{ + QAction *qtAction = GetActionAt( m_qtMenuBar, pos ); + return qtAction->isEnabled(); +} + void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { From bfad2a5425cc1e97362081180c0a64b85daae3ff Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 21 Nov 2018 16:02:33 +0000 Subject: [PATCH 107/140] Fix menu first radio button state and synchronise state changes. --- src/qt/menu.cpp | 3 ++- src/qt/menuitem.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qt/menu.cpp b/src/qt/menu.cpp index e0f7d8c5fc..1b810cecd9 100644 --- a/src/qt/menu.cpp +++ b/src/qt/menu.cpp @@ -53,7 +53,7 @@ static wxMenuItem *GetMenuItemAt( const wxMenu *menu, size_t position ) static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previousItem, - const wxMenuItem *item, const wxMenuItem *successiveItem ) + wxMenuItem *item, const wxMenuItem *successiveItem ) { QMenu *qtMenu = menu->GetHandle(); QAction *itemAction = item->GetHandle(); @@ -74,6 +74,7 @@ static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previous { QActionGroup *actionGroup = new QActionGroup( qtMenu ); actionGroup->addAction( itemAction ); + item->Check(); wxASSERT_MSG( itemAction->actionGroup() == actionGroup, "Must be the same action group" ); } break; diff --git a/src/qt/menuitem.cpp b/src/qt/menuitem.cpp index 6ce89dc5be..328e65c892 100644 --- a/src/qt/menuitem.cpp +++ b/src/qt/menuitem.cpp @@ -165,5 +165,6 @@ void wxQtAction::onActionTriggered( bool checked ) { wxMenuItem *handler = GetHandler(); wxMenu *menu = handler->GetMenu(); + if(handler->IsCheckable()) handler->Check(checked); menu->SendEvent( handler->GetId(), handler->IsCheckable() ? checked : -1 ); } From 82f8fad24052f48b481c1a926b752c42e7d4456b Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 22 Nov 2018 10:22:39 +0000 Subject: [PATCH 108/140] Split out test which will not work on QT, and fix insertion behaviour of radio menu items. --- src/qt/menu.cpp | 7 ++++++ tests/menu/menu.cpp | 55 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/qt/menu.cpp b/src/qt/menu.cpp index 1b810cecd9..c346a1641c 100644 --- a/src/qt/menu.cpp +++ b/src/qt/menu.cpp @@ -70,6 +70,13 @@ static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previous wxASSERT_MSG( previousItemActionGroup != NULL, "An action group should have been setup" ); previousItemActionGroup->addAction( itemAction ); } + else if( successiveItem != NULL && successiveItem->GetKind() == wxITEM_RADIO ) + { + QAction *successiveItemAction = successiveItem->GetHandle(); + QActionGroup *successiveItemActionGroup = successiveItemAction->actionGroup(); + wxASSERT_MSG( successiveItemActionGroup != NULL, "An action group should have been setup" ); + successiveItemActionGroup->addAction( itemAction ); + } else { QActionGroup *actionGroup = new QActionGroup( qtMenu ); diff --git a/tests/menu/menu.cpp b/tests/menu/menu.cpp index dbda30cb74..8c0547b78c 100644 --- a/tests/menu/menu.cpp +++ b/tests/menu/menu.cpp @@ -90,7 +90,11 @@ private: #if wxUSE_INTL CPPUNIT_TEST( TranslatedMnemonics ); #endif // wxUSE_INTL +#ifndef __WXQT__ CPPUNIT_TEST( RadioItems ); +#else + CPPUNIT_TEST( RadioItemsWithoutMutualExclusion ); +#endif CPPUNIT_TEST( RemoveAdd ); CPPUNIT_TEST( ChangeBitmap ); WXUISIM_TEST( Events ); @@ -107,6 +111,7 @@ private: void TranslatedMnemonics(); #endif // wxUSE_INTL void RadioItems(); + void RadioItemsWithoutMutualExclusion(); void RemoveAdd(); void ChangeBitmap(); void Events(); @@ -425,7 +430,6 @@ void MenuTestCase::RadioItems() CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 2) ); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) ); - // Insert an item in the middle of an existing radio group. menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5"); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) ); @@ -433,13 +437,56 @@ void MenuTestCase::RadioItems() menu->Check( MenuTestCase_First + 5, true ); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 3) ); + // Prepend a couple of items before the first group. + menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6"); + menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7"); + + // Items should not be checked, as they are part of an existing group. + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 6) ); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 7) ); + menu->Check(MenuTestCase_First + 7, true); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); + + // Check that the last radio group still works as expected. + menu->Check(MenuTestCase_First + 4, true); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) ); +} + +void MenuTestCase::RadioItemsWithoutMutualExclusion() +{ + wxMenuBar * const bar = m_frame->GetMenuBar(); + wxMenu * const menu = new wxMenu; + bar->Append(menu, "&Radio"); + + // Adding consecutive radio items creates a radio group. + menu->AppendRadioItem(MenuTestCase_First, "Radio 0"); + menu->AppendRadioItem(MenuTestCase_First + 1, "Radio 1"); + + // First item of a radio group is checked by default. + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); + + // Subsequent items in a group are not checked. + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); + + // Adding more radio items after a separator creates another radio group... + menu->AppendSeparator(); + menu->AppendRadioItem(MenuTestCase_First + 2, "Radio 2"); + menu->AppendRadioItem(MenuTestCase_First + 3, "Radio 3"); + menu->AppendRadioItem(MenuTestCase_First + 4, "Radio 4"); + + // ... which is independent from the first one. + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); + + // Insert an item in the middle of an existing radio group. + menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5"); + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); // Prepend a couple of items before the first group. menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6"); menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7"); - menu->Check(MenuTestCase_First + 7, true); - CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); - + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 6) ); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 7) ); // Check that the last radio group still works as expected. menu->Check(MenuTestCase_First + 4, true); From 902ce48189e49f95977435a587683b46dc36b51b Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 22 Nov 2018 10:35:40 +0000 Subject: [PATCH 109/140] Remove duplicated code. --- src/qt/menu.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/qt/menu.cpp b/src/qt/menu.cpp index c346a1641c..e81e237f96 100644 --- a/src/qt/menu.cpp +++ b/src/qt/menu.cpp @@ -51,6 +51,13 @@ static wxMenuItem *GetMenuItemAt( const wxMenu *menu, size_t position ) return NULL; } +static void AddItemActionToGroup( const wxMenuItem *groupItem, QAction *itemAction ) +{ + QAction *groupItemAction = groupItem->GetHandle(); + QActionGroup *itemActionGroup = groupItemAction->actionGroup(); + wxASSERT_MSG( itemActionGroup != NULL, "An action group should have been setup" ); + itemActionGroup->addAction( itemAction ); +} static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previousItem, wxMenuItem *item, const wxMenuItem *successiveItem ) @@ -60,22 +67,16 @@ static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previous switch ( item->GetKind() ) { case wxITEM_RADIO: - // If the previous menu item is a radio item then add this item to the + // If a neighbouring menu item is a radio item then add this item to the // same action group, otherwise start a new group: if ( previousItem != NULL && previousItem->GetKind() == wxITEM_RADIO ) { - QAction *previousItemAction = previousItem->GetHandle(); - QActionGroup *previousItemActionGroup = previousItemAction->actionGroup(); - wxASSERT_MSG( previousItemActionGroup != NULL, "An action group should have been setup" ); - previousItemActionGroup->addAction( itemAction ); + AddItemActionToGroup( previousItem, itemAction ); } else if( successiveItem != NULL && successiveItem->GetKind() == wxITEM_RADIO ) { - QAction *successiveItemAction = successiveItem->GetHandle(); - QActionGroup *successiveItemActionGroup = successiveItemAction->actionGroup(); - wxASSERT_MSG( successiveItemActionGroup != NULL, "An action group should have been setup" ); - successiveItemActionGroup->addAction( itemAction ); + AddItemActionToGroup( successiveItem, itemAction ); } else { From 74f60d90a6d67f1e167bd37d8d09ec8f25dbf7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Thu, 22 Nov 2018 12:38:29 +0000 Subject: [PATCH 110/140] Update src/qt/menuitem.cpp Co-Authored-By: evileye-uk --- src/qt/menuitem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/menuitem.cpp b/src/qt/menuitem.cpp index 328e65c892..fa729e33de 100644 --- a/src/qt/menuitem.cpp +++ b/src/qt/menuitem.cpp @@ -165,6 +165,7 @@ void wxQtAction::onActionTriggered( bool checked ) { wxMenuItem *handler = GetHandler(); wxMenu *menu = handler->GetMenu(); - if(handler->IsCheckable()) handler->Check(checked); + if ( handler->IsCheckable() ) + handler->Check(checked); menu->SendEvent( handler->GetId(), handler->IsCheckable() ? checked : -1 ); } From 69c19f29cae0ecbce53f3e495dac93a6b0466660 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 22 Nov 2018 22:32:08 +0000 Subject: [PATCH 111/140] Restore menu tests, excluding QT where appropriate. --- tests/menu/menu.cpp | 78 +++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 49 deletions(-) diff --git a/tests/menu/menu.cpp b/tests/menu/menu.cpp index 8c0547b78c..6e6cd6f36b 100644 --- a/tests/menu/menu.cpp +++ b/tests/menu/menu.cpp @@ -90,11 +90,7 @@ private: #if wxUSE_INTL CPPUNIT_TEST( TranslatedMnemonics ); #endif // wxUSE_INTL -#ifndef __WXQT__ CPPUNIT_TEST( RadioItems ); -#else - CPPUNIT_TEST( RadioItemsWithoutMutualExclusion ); -#endif CPPUNIT_TEST( RemoveAdd ); CPPUNIT_TEST( ChangeBitmap ); WXUISIM_TEST( Events ); @@ -111,7 +107,6 @@ private: void TranslatedMnemonics(); #endif // wxUSE_INTL void RadioItems(); - void RadioItemsWithoutMutualExclusion(); void RemoveAdd(); void ChangeBitmap(); void Events(); @@ -411,10 +406,18 @@ void MenuTestCase::RadioItems() // First item of a radio group is checked by default. CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); + // Subsequent items in a group are not checked. + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); + +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else // Checking the second one make the first one unchecked however. menu->Check(MenuTestCase_First + 1, true); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First) ); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) ); + menu->Check(MenuTestCase_First, true); +#endif // Adding more radio items after a separator creates another radio group... menu->AppendSeparator(); @@ -423,74 +426,51 @@ void MenuTestCase::RadioItems() menu->AppendRadioItem(MenuTestCase_First + 4, "Radio 4"); // ... which is independent from the first one. + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else menu->Check(MenuTestCase_First + 3, true); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) ); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 2) ); - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) ); + + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); + menu->Check(MenuTestCase_First + 2, true); +#endif // Insert an item in the middle of an existing radio group. menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5"); - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) ); + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) ); +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else menu->Check( MenuTestCase_First + 5, true ); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 3) ); + menu->Check( MenuTestCase_First + 3, true ); +#endif + // Prepend a couple of items before the first group. menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6"); menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7"); - - // Items should not be checked, as they are part of an existing group. CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 6) ); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 7) ); + +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else menu->Check(MenuTestCase_First + 7, true); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); - // Check that the last radio group still works as expected. - menu->Check(MenuTestCase_First + 4, true); - CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) ); -} - -void MenuTestCase::RadioItemsWithoutMutualExclusion() -{ - wxMenuBar * const bar = m_frame->GetMenuBar(); - wxMenu * const menu = new wxMenu; - bar->Append(menu, "&Radio"); - - // Adding consecutive radio items creates a radio group. - menu->AppendRadioItem(MenuTestCase_First, "Radio 0"); - menu->AppendRadioItem(MenuTestCase_First + 1, "Radio 1"); - - // First item of a radio group is checked by default. - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); - - // Subsequent items in a group are not checked. - CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); - - // Adding more radio items after a separator creates another radio group... - menu->AppendSeparator(); - menu->AppendRadioItem(MenuTestCase_First + 2, "Radio 2"); - menu->AppendRadioItem(MenuTestCase_First + 3, "Radio 3"); - menu->AppendRadioItem(MenuTestCase_First + 4, "Radio 4"); - - // ... which is independent from the first one. - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); - - // Insert an item in the middle of an existing radio group. - menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5"); - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); - - // Prepend a couple of items before the first group. - menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6"); - menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7"); - CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 6) ); - CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 7) ); // Check that the last radio group still works as expected. menu->Check(MenuTestCase_First + 4, true); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) ); +#endif } void MenuTestCase::RemoveAdd() From 5b0dcfec8387d53041dfc5231311492d77fd21ea Mon Sep 17 00:00:00 2001 From: Teodor Petrov Date: Wed, 15 Aug 2018 08:30:27 +0300 Subject: [PATCH 112/140] Add wxArrayString pretty printer for gdb Closes #18276. --- misc/gdb/print.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/misc/gdb/print.py b/misc/gdb/print.py index 28d47d6276..8408087ad7 100755 --- a/misc/gdb/print.py +++ b/misc/gdb/print.py @@ -14,6 +14,20 @@ # in wxLookupFunction at the bottom of this file. import datetime +import gdb +import itertools +import sys + +if sys.version_info[0] > 2: + # Python 3 + Iterator = object + + long = int +else: + # Python 2, we need to make an adaptor, so we can use Python 3 iterator implementations. + class Iterator: + def next(self): + return self.__next__() # shamelessly stolen from std::string example class wxStringPrinter: @@ -26,6 +40,41 @@ class wxStringPrinter: def display_hint(self): return 'string' +class wxArrayStringPrinter: + + class _iterator(Iterator): + def __init__ (self, firstItem, count): + self.item = firstItem + self.count = count + self.current = 0 + + def __iter__(self): + return self + + def __next__(self): + current = self.current + self.current = self.current + 1 + + if current == self.count: + raise StopIteration + elt = self.item.dereference() + self.item = self.item + 1 + return ('[%d]' % current, elt) + + def __init__(self, val): + self.val = val + + def children(self): + return self._iterator(self.val['m_pItems'], self.val['m_nCount']) + + def to_string(self): + count = self.val['m_nCount'] + capacity = self.val['m_nSize'] + return ('length %d, capacity %d' % (int (count), int (capacity))) + + def display_hint(self): + return 'array' + class wxDateTimePrinter: def __init__(self, val): self.val = val @@ -81,6 +130,7 @@ def wxLookupFunction(val): # Using a list is probably ok for so few items but consider switching to a # set (or a dict and cache class types as the keys in it?) if needed later. types = ['wxString', + 'wxArrayString', 'wxDateTime', 'wxFileName', 'wxPoint', From 86c49283f581d1802db96eb41b324803dad65f00 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 25 Nov 2018 20:22:25 +0100 Subject: [PATCH 113/140] Remove trailing spaces --- interface/wx/grid.h | 10 +++---- src/aui/framemanager.cpp | 2 +- src/common/dcgraph.cpp | 16 +++++----- src/generic/treectlg.cpp | 6 ++-- src/msw/utils.cpp | 2 +- src/osx/carbon/dcprint.cpp | 2 +- src/osx/carbon/graphics.cpp | 56 +++++++++++++++++------------------ src/osx/carbon/statbrma.cpp | 2 +- src/propgrid/propgrid.cpp | 2 +- src/qt/dc.cpp | 48 +++++++++++++++--------------- src/richtext/richtextctrl.cpp | 8 ++--- 11 files changed, 77 insertions(+), 77 deletions(-) diff --git a/interface/wx/grid.h b/interface/wx/grid.h index 1546607b5d..f020cab80a 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -987,7 +987,7 @@ public: */ void SetTextColour(const wxColour& colText); - + void MergeWith(wxGridCellAttr *mergefrom); void SetSize(int num_rows, int num_cols); @@ -4551,7 +4551,7 @@ public: */ void SetRowAttr(int row, wxGridCellAttr* attr); - + wxArrayInt CalcRowLabelsExposed( const wxRegion& reg ); wxArrayInt CalcColLabelsExposed( const wxRegion& reg ); wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg ); @@ -4697,7 +4697,7 @@ public: virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ); - + virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows ); virtual void DrawRowLabel( wxDC& dc, int row ); @@ -4722,9 +4722,9 @@ public: void SetCellHighlightColour( const wxColour& ); void SetCellHighlightPenWidth(int width); - void SetCellHighlightROPenWidth(int width); + void SetCellHighlightROPenWidth(int width); + - protected: /** Returns @true if this grid has support for cell attributes. diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 27b1f0c08a..088f8eecd2 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -3898,7 +3898,7 @@ void wxAuiManager::Render(wxDC* dc) void wxAuiManager::Repaint(wxDC* dc) { -#ifdef __WXMAC__ +#ifdef __WXMAC__ if ( dc == NULL ) { m_frame->Refresh() ; diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 292d058220..09e56194e8 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -1107,20 +1107,20 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, if ( (angle == 0.0) && m_font.IsOk() ) { DoDrawText(text, x, y); - + // Bounding box already updated by DoDrawText(), no need to do it again. return; } - + // Get extent of whole text. wxCoord w, h, heightLine; GetOwner()->GetMultiLineTextExtent(text, &w, &h, &heightLine); - + // Compute the shift for the origin of the next line. const double rad = wxDegToRad(angle); const double dx = heightLine * sin(rad); const double dy = heightLine * cos(rad); - + // Draw all text line by line const wxArrayString lines = wxSplit(text, '\n', '\0'); for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ ) @@ -1132,15 +1132,15 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, else m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) ); } - + // call the bounding box by adding all four vertices of the rectangle // containing the text to it (simpler and probably not slower than // determining which of them is really topmost/leftmost/...) - + // "upper left" and "upper right" CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); - + // "bottom left" and "bottom right" x += (wxCoord)(h*sin(rad)); y += (wxCoord)(h*cos(rad)); @@ -1254,7 +1254,7 @@ wxCoord wxGCDCImpl::GetCharHeight(void) const void wxGCDCImpl::Clear(void) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::Clear - invalid DC") ); - + if ( m_backgroundBrush.IsOk() ) { m_graphicContext->SetBrush( m_backgroundBrush ); diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index de0fe661fc..7e05d37586 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -2292,7 +2292,7 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) // update the control before scrolling it if (m_dirty) { -#if defined( __WXMSW__ ) +#if defined( __WXMSW__ ) Update(); #elif defined(__WXMAC__) Update(); @@ -2301,7 +2301,7 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) DoDirtyProcessing(); #endif } - + wxGenericTreeItem *gitem = (wxGenericTreeItem*) item.m_pItem; int itemY = gitem->GetY(); @@ -2320,7 +2320,7 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) itemY += itemHeight - clientHeight; // because itemY below will be divided by PIXELS_PER_UNIT it may - // be rounded down, with the result of the item still only being + // be rounded down, with the result of the item still only being // partially visible, so make sure we are rounding up itemY += PIXELS_PER_UNIT - 1; } diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 2fc500a202..45f52c8d77 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -1270,7 +1270,7 @@ wxWinVersion wxGetWinVersion() } break; - + case 10: return wxWinVersion_10; } diff --git a/src/osx/carbon/dcprint.cpp b/src/osx/carbon/dcprint.cpp index 9c4978f843..e3346689b9 100644 --- a/src/osx/carbon/dcprint.cpp +++ b/src/osx/carbon/dcprint.cpp @@ -149,7 +149,7 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& message if (m_err == noErr) useDefaultResolution = true; } - + // Ignore errors which may occur while retrieving the resolution and just // use the default one. if ( useDefaultResolution ) diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index c8a926ec79..e231531450 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -1352,7 +1352,7 @@ public: virtual bool SetAntialiasMode(wxAntialiasMode antialias) wxOVERRIDE; virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation) wxOVERRIDE; - + virtual bool SetCompositionMode(wxCompositionMode op) wxOVERRIDE; virtual void BeginLayer(wxDouble opacity) wxOVERRIDE; @@ -1392,15 +1392,15 @@ public: // draws a path by first filling and then stroking virtual void DrawPath( const wxGraphicsPath &path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ) wxOVERRIDE; - + // paints a transparent rectangle (only useful for bitmaps or windows) virtual void ClearRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h) wxOVERRIDE; - + virtual bool ShouldOffset() const wxOVERRIDE { if ( !m_enableOffset ) return false; - + int penwidth = 0 ; if ( !m_pen.IsNull() ) { @@ -1428,10 +1428,10 @@ public: virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE; virtual void DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE; - + // fast convenience methods - - + + virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE; void SetNativeContext( CGContextRef cg ); @@ -1617,7 +1617,7 @@ void wxMacCoreGraphicsContext::Flush() bool wxMacCoreGraphicsContext::EnsureIsValid() { CheckInvariants(); - + if ( !m_cgContext ) { if (m_invisible) @@ -1729,7 +1729,7 @@ bool wxMacCoreGraphicsContext::SetInterpolationQuality(wxInterpolationQuality in { if (!EnsureIsValid()) return true; - + if (m_interpolation == interpolation) return true; @@ -1944,7 +1944,7 @@ void wxMacCoreGraphicsContext::Clip( const wxRegion ®ion ) // allow usage as measuring context // wxASSERT_MSG( m_cgContext != NULL, "Needs a valid context for clipping" ); #endif - CheckInvariants(); + CheckInvariants(); } // clips drawings to the rect @@ -1969,7 +1969,7 @@ void wxMacCoreGraphicsContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDoubl // wxFAIL_MSG( "Needs a valid context for clipping" ); #endif } - CheckInvariants(); + CheckInvariants(); } // resets the clipping to original extent @@ -2002,7 +2002,7 @@ void wxMacCoreGraphicsContext::ResetClip() // wxFAIL_MSG( "Needs a valid context for clipping" ); #endif } - CheckInvariants(); + CheckInvariants(); } void wxMacCoreGraphicsContext::GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) @@ -2056,7 +2056,7 @@ void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath &path ) ((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->Apply(this); CGContextAddPath( m_cgContext , (CGPathRef) path.GetNativePath() ); CGContextStrokePath( m_cgContext ); - + CheckInvariants(); } @@ -2111,7 +2111,7 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath &path , wxPolygonF CGContextAddPath( m_cgContext , (CGPathRef) path.GetNativePath() ); CGContextDrawPath( m_cgContext , mode ); - + CheckInvariants(); } @@ -2143,7 +2143,7 @@ void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath &path , wxPolygonF else CGContextFillPath( m_cgContext ); } - + CheckInvariants(); } @@ -2263,7 +2263,7 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble wxMacDrawCGImage( m_cgContext , &r , image ); } #endif - + CheckInvariants(); } @@ -2281,7 +2281,7 @@ void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDoubl wxOSXDrawNSImage( m_cgContext, &r, icon.GetImage()); } #endif - + CheckInvariants(); } @@ -2318,9 +2318,9 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo wxCFDictionaryRef fontattr(wxCFRetain(fref->OSXGetCTFontAttributes())); wxCFMutableDictionaryRef inlinefontattr; - + bool setColorsInLine = false; - + // if we emulate boldness the stroke color is not taken from the current context // therefore we have to set it explicitly if ( fontattr.GetValue(kCTStrokeWidthAttributeName) != NULL) @@ -2331,7 +2331,7 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo inlinefontattr.SetValue(kCTForegroundColorAttributeName,col); inlinefontattr.SetValue(kCTStrokeColorAttributeName,col); } - + wxCFRef attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, setColorsInLine ? inlinefontattr : fontattr ) ); wxCFRef line( CTLineCreateWithAttributedString(attrtext) ); @@ -2352,7 +2352,7 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo CGFloat width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CGPoint points[] = { {0.0, -2.0}, {width, -2.0} }; - + CGContextSetStrokeColorWithColor(m_cgContext, col); CGContextSetShouldAntialias(m_cgContext, false); CGContextSetLineWidth(m_cgContext, 1.0); @@ -2417,7 +2417,7 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData(); wxCFStringRef text(strToMeasure, wxLocale::GetSystemEncoding() ); - + wxCFRef attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, fref->OSXGetCTFontAttributes() ) ); wxCFRef line( CTLineCreateWithAttributedString(attrtext) ); @@ -2436,7 +2436,7 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid if ( externalLeading ) *externalLeading = l; - CheckInvariants(); + CheckInvariants(); } void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const @@ -2479,7 +2479,7 @@ void wxMacCoreGraphicsContext::ClearRectangle( wxDouble x, wxDouble y, wxDouble { if (!EnsureIsValid()) return; - + CGRect rect = CGRectMake( (CGFloat) x , (CGFloat) y , (CGFloat) w , (CGFloat) h ); CGContextClearRect(m_cgContext, rect); } @@ -2489,10 +2489,10 @@ void wxMacCoreGraphicsContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w if (!EnsureIsValid()) return; - if (m_composition == wxCOMPOSITION_DEST) - return; + if (m_composition == wxCOMPOSITION_DEST) + return; - // when using shading, we have to go back to drawing paths + // when using shading, we have to go back to drawing paths if ( !m_brush.IsNull() && ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() ) { wxGraphicsContext::DrawRectangle( x,y,w,h ); @@ -2505,7 +2505,7 @@ void wxMacCoreGraphicsContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this); CGContextFillRect(m_cgContext, rect); } - + wxQuartzOffsetHelper helper( m_cgContext , ShouldOffset() ); if ( !m_pen.IsNull() ) { diff --git a/src/osx/carbon/statbrma.cpp b/src/osx/carbon/statbrma.cpp index 1685619090..7f996df201 100644 --- a/src/osx/carbon/statbrma.cpp +++ b/src/osx/carbon/statbrma.cpp @@ -110,7 +110,7 @@ void wxStatusBarMac::InitColours() wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); m_textActive = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT); m_textInactive = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); - + if ( bg.Red() < 128 ) { // dark mode appearance diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index fc76cfb8e0..e46c2183e0 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -1427,7 +1427,7 @@ void wxPropertyGrid::RegainColours() wxColour capForeCol = wxPGAdjustColour(m_colCapBack,colDec,5000,5000,true); if (wxPGGetColAvg(m_colCapBack) < 100) capForeCol = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); - + m_colCapFore = capForeCol; m_categoryDefaultCell.GetData()->SetFgCol(capForeCol); } diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 38e4e0af21..ffa67458d1 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -159,7 +159,7 @@ void wxQtDCImpl::SetPen(const wxPen& pen) void wxQtDCImpl::SetBrush(const wxBrush& brush) { m_brush = brush; - + if (brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) { // Use a monochrome mask: use foreground color for the mask @@ -190,7 +190,7 @@ void wxQtDCImpl::SetBrush(const wxBrush& brush) void wxQtDCImpl::SetBackground(const wxBrush& brush) { m_backgroundBrush = brush; - + if (m_qtPainter->isActive()) m_qtPainter->setBackground(brush.GetHandle()); } @@ -375,7 +375,7 @@ void wxQtDCImpl::Clear() { int width, height; DoGetSize(&width, &height); - + m_qtPainter->eraseRect(QRect(0, 0, width, height)); } @@ -486,7 +486,7 @@ bool wxQtDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const if ( col ) { wxCHECK_MSG( m_qtImage != NULL, false, "This DC doesn't support GetPixel()" ); - + QColor pixel = m_qtImage->pixel( x, y ); col->Set( pixel.red(), pixel.green(), pixel.blue(), pixel.alpha() ); @@ -519,7 +519,7 @@ void wxQtDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, qreal penWidth = m_qtPainter->pen().width(); qreal lenRadius = l1.length() - penWidth / 2; QPointF centerToCorner( lenRadius, lenRadius ); - + QRect rectangle = QRectF( center - centerToCorner, center + centerToCorner ).toRect(); // Calculate the angles @@ -530,7 +530,7 @@ void wxQtDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, { spanAngle = -spanAngle; } - + if ( spanAngle == 0 ) m_qtPainter->drawEllipse( rectangle ); else @@ -578,7 +578,7 @@ void wxQtDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, y += penWidth / 2; width -= penWidth; height -= penWidth; - + m_qtPainter->drawRoundedRect( x, y, width, height, radius, radius ); } @@ -591,7 +591,7 @@ void wxQtDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, y += penWidth / 2; width -= penWidth; height -= penWidth; - + if ( m_pen.IsNonTransparent() ) { // Save pen/brush @@ -620,7 +620,7 @@ void wxQtDCImpl::DoCrossHair(wxCoord x, wxCoord y) int left, top, right, bottom; inv.map( w, h, &right, &bottom ); inv.map( 0, 0, &left, &top ); - + m_qtPainter->drawLine( left, y, right, y ); m_qtPainter->drawLine( x, top, x, bottom ); } @@ -636,18 +636,18 @@ void wxQtDCImpl::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, QPixmap pix = *bmp.GetHandle(); if (pix.depth() == 1) { //Monochrome bitmap, draw using text fore/background - + //Save pen/brush QBrush savedBrush = m_qtPainter->background(); QPen savedPen = m_qtPainter->pen(); - + //Use text colors m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetQColor())); m_qtPainter->setPen(QPen(m_textForegroundColour.GetQColor())); //Draw m_qtPainter->drawPixmap(x, y, pix); - + //Restore saved settings m_qtPainter->setBackground(savedBrush); m_qtPainter->setPen(savedPen); @@ -668,11 +668,11 @@ void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) // Disable logical function QPainter::CompositionMode savedOp = m_qtPainter->compositionMode(); m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver ); - + if (m_backgroundMode == wxSOLID) { m_qtPainter->setBackgroundMode(Qt::OpaqueMode); - + //Save pen/brush QBrush savedBrush = m_qtPainter->background(); @@ -700,7 +700,7 @@ void wxQtDCImpl::DoDrawRotatedText(const wxString& text, { if (m_backgroundMode == wxSOLID) m_qtPainter->setBackgroundMode(Qt::OpaqueMode); - + //Move and rotate (reverse angle direction in Qt and wx) m_qtPainter->translate(x, y); m_qtPainter->rotate(-angle); @@ -715,19 +715,19 @@ void wxQtDCImpl::DoDrawRotatedText(const wxString& text, if (m_backgroundMode == wxSOLID) { m_qtPainter->setBackgroundMode(Qt::OpaqueMode); - + //Save pen/brush QBrush savedBrush = m_qtPainter->background(); - + //Use text colors m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetQColor())); - + //Draw m_qtPainter->drawText(x, y, 1, 1, Qt::TextDontClip, wxQtConvertString(text)); - + //Restore saved settings m_qtPainter->setBackground(savedBrush); - + m_qtPainter->setBackgroundMode(Qt::TransparentMode); } else @@ -749,9 +749,9 @@ bool wxQtDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord WXUNUSED(ysrcMask) ) { wxQtDCImpl *implSource = (wxQtDCImpl*)source->GetImpl(); - + QImage *qtSource = implSource->GetQImage(); - + // Not a CHECK on purpose if ( !qtSource ) return false; @@ -763,7 +763,7 @@ bool wxQtDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, // Change logical function wxRasterOperationMode savedMode = GetLogicalFunction(); SetLogicalFunction( rop ); - + m_qtPainter->drawImage( QRect( xdest, ydest, width, height ), qtSourceConverted, QRect( xsrc, ysrc, width, height ) ); @@ -806,7 +806,7 @@ void wxQtDCImpl::DoDrawPolygon(int n, const wxPoint points[], } Qt::FillRule fill = (fillStyle == wxWINDING_RULE) ? Qt::WindingFill : Qt::OddEvenFill; - + m_qtPainter->translate(xoffset, yoffset); m_qtPainter->drawPolygon(qtPoints, fill); // Reset transform diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 2c93417aee..0fb71e4cad 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -242,7 +242,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va const wxValidator& validator, const wxString& name) { style |= wxVSCROLL; - + // If read-only, the programmer probably wants to retain dialog keyboard navigation. // If you don't, then pass wxWANTS_CHARS explicitly. if ((style & wxTE_READONLY) == 0) @@ -2180,7 +2180,7 @@ bool wxRichTextCtrl::MoveRight(int noPositions, int flags) SetFocusObject(actualContainer, false /* don't set caret position yet */); bool caretLineStart = true; long caretPosition = FindCaretPositionForCharacterPosition(newPos, hitTest, actualContainer, caretLineStart); - + SelectNone(); SetCaretPosition(caretPosition, caretLineStart); @@ -2511,7 +2511,7 @@ bool wxRichTextCtrl::StartCellSelection(wxRichTextTable* table, wxRichTextParagr SetFocusObject(newCell, false /* don't set caret and clear selection */); MoveCaret(-1, false); SetDefaultStyleToCursorStyle(); - + return true; } @@ -3001,7 +3001,7 @@ void wxRichTextCtrl::SetupScrollbars(bool atTop, bool fromOnPaint) doSetScrollbars = false; } } - + m_lastWindowSize = windowSize; m_setupScrollbarsCount ++; if (m_setupScrollbarsCount > 32000) From 39ff5b90e54f3e2d6a4434c1a1a5f9f75cd60465 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 25 Nov 2018 20:22:35 +0100 Subject: [PATCH 114/140] Replace wxDeprecatedGUIConstants enum values --- demos/forty/card.cpp | 4 +- demos/forty/game.cpp | 2 +- demos/poem/wxpoem.cpp | 2 +- docs/doxygen/overviews/commondialogs.h | 2 +- include/wx/html/htmlcell.h | 2 +- interface/wx/grid.h | 2 +- samples/caret/caret.cpp | 2 +- samples/dialogs/dialogs.cpp | 2 +- samples/drawing/drawing.cpp | 9 +- samples/erase/erase.cpp | 4 +- samples/printing/printing.cpp | 4 +- samples/svg/svgtest.cpp | 2 +- src/aui/auibar.cpp | 2 +- src/aui/framemanager.cpp | 2 +- src/common/dcgraph.cpp | 4 +- src/common/fontcmn.cpp | 4 +- src/common/glcmn.cpp | 2 +- src/dfb/brush.cpp | 4 +- src/dfb/dc.cpp | 10 +-- src/dfb/pen.cpp | 2 +- src/generic/buttonbar.cpp | 2 +- src/generic/calctrlg.cpp | 2 +- src/generic/datavgen.cpp | 2 +- src/generic/dcpsg.cpp | 14 ++-- src/generic/headerctrlg.cpp | 2 +- src/generic/markuptext.cpp | 6 +- src/generic/renderg.cpp | 4 +- src/generic/splitter.cpp | 2 +- src/generic/tabg.cpp | 4 +- src/generic/treectlg.cpp | 2 +- src/generic/vlbox.cpp | 2 +- src/gtk1/control.cpp | 2 +- src/gtk1/dcclient.cpp | 98 +++++++++++----------- src/gtk1/font.cpp | 2 +- src/gtk1/settings.cpp | 2 +- src/gtk1/window.cpp | 8 +- src/html/htmlcell.cpp | 12 +-- src/html/htmlwin.cpp | 2 +- src/html/htmprint.cpp | 2 +- src/html/m_fonts.cpp | 2 +- src/html/m_links.cpp | 2 +- src/html/m_span.cpp | 2 +- src/html/winpars.cpp | 6 +- src/motif/dc.cpp | 2 +- src/motif/dcclient.cpp | 110 ++++++++++++------------- src/motif/settings.cpp | 4 +- src/motif/utils.cpp | 2 +- src/motif/window.cpp | 4 +- src/msw/dc.cpp | 16 ++-- src/msw/dcmemory.cpp | 8 +- src/msw/mediactrl_am.cpp | 2 +- src/msw/mediactrl_wmp10.cpp | 2 +- src/osx/carbon/dcprint.cpp | 2 +- src/osx/carbon/graphics.cpp | 12 +-- src/osx/carbon/statbrma.cpp | 2 +- src/propgrid/editors.cpp | 2 +- src/propgrid/propgrid.cpp | 2 +- src/qt/dc.cpp | 6 +- src/ribbon/art_aui.cpp | 2 +- src/ribbon/art_msw.cpp | 2 +- src/ribbon/bar.cpp | 2 +- src/ribbon/buttonbar.cpp | 2 +- src/ribbon/gallery.cpp | 2 +- src/ribbon/page.cpp | 4 +- src/ribbon/panel.cpp | 2 +- src/ribbon/toolbar.cpp | 2 +- src/richtext/richtextbuffer.cpp | 2 +- src/richtext/richtextctrl.cpp | 2 +- src/richtext/richtextsymboldlg.cpp | 2 +- src/stc/ScintillaWX.cpp | 2 +- src/univ/ctrlrend.cpp | 4 +- src/univ/notebook.cpp | 2 +- src/univ/stdrend.cpp | 6 +- src/univ/themes/mono.cpp | 2 +- src/unix/fontutil.cpp | 8 +- src/unix/mediactrl.cpp | 2 +- src/unix/mediactrl_gstplayer.cpp | 2 +- src/x11/dc.cpp | 2 +- src/x11/dcclient.cpp | 28 +++---- src/x11/font.cpp | 2 +- src/x11/textctrl.cpp | 4 +- 81 files changed, 257 insertions(+), 256 deletions(-) diff --git a/demos/forty/card.cpp b/demos/forty/card.cpp index 316c49361b..6b08cf850e 100644 --- a/demos/forty/card.cpp +++ b/demos/forty/card.cpp @@ -165,7 +165,7 @@ void Card::Draw(wxDC& dc, int x, int y) if (m_wayUp == facedown) { dc.SetBackground(* wxRED_BRUSH); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); wxBrush* brush = wxTheBrushList->FindOrCreateBrush( *wxBLACK, wxBRUSHSTYLE_CROSSDIAG_HATCH ); @@ -183,7 +183,7 @@ void Card::Draw(wxDC& dc, int x, int y) memoryDC.SelectObject(*m_symbolBmap); -// dc.SetBackgroundMode(wxTRANSPARENT); +// dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetTextBackground(*wxWHITE); switch (m_suit) diff --git a/demos/forty/game.cpp b/demos/forty/game.cpp index 894077e8b7..c99ba72ba9 100644 --- a/demos/forty/game.cpp +++ b/demos/forty/game.cpp @@ -795,7 +795,7 @@ void Pack::Redraw(wxDC& dc) wxString str; str.Printf(wxT("%d "), m_topCard + 1); - dc.SetBackgroundMode( wxSOLID ); + dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID ); dc.SetTextBackground(FortyApp::BackgroundColour()); dc.SetTextForeground(FortyApp::TextColour()); dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2); diff --git a/demos/poem/wxpoem.cpp b/demos/poem/wxpoem.cpp index 36206c8753..5b0500e0d7 100644 --- a/demos/poem/wxpoem.cpp +++ b/demos/poem/wxpoem.cpp @@ -168,7 +168,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) dc->SetBrush(*wxLIGHT_GREY_BRUSH); dc->SetPen(*wxGREY_PEN); dc->DrawRectangle(0, 0, width, height); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); } // See what ACTUAL char height is diff --git a/docs/doxygen/overviews/commondialogs.h b/docs/doxygen/overviews/commondialogs.h index 5a69090d3d..e1affa2f63 100644 --- a/docs/doxygen/overviews/commondialogs.h +++ b/docs/doxygen/overviews/commondialogs.h @@ -78,7 +78,7 @@ if (dialog.ShowModal() == wxID_OK) { wxColourData retData = dialog.GetColourData(); wxColour col = retData.GetColour(); - wxBrush brush(col, wxSOLID); + wxBrush brush(col, wxBRUSHSTYLE_SOLID); myWindow->SetBackground(brush); myWindow->Clear(); myWindow->Refresh(); diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index 083ebd8e63..c02a128143 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -81,7 +81,7 @@ enum wxHtmlSelectionState class WXDLLIMPEXP_HTML wxHtmlRenderingState { public: - wxHtmlRenderingState() : m_selState(wxHTML_SEL_OUT) { m_bgMode = wxSOLID; } + wxHtmlRenderingState() : m_selState(wxHTML_SEL_OUT) { m_bgMode = wxBRUSHSTYLE_SOLID; } void SetSelectionState(wxHtmlSelectionState s) { m_selState = s; } wxHtmlSelectionState GetSelectionState() const { return m_selState; } diff --git a/interface/wx/grid.h b/interface/wx/grid.h index f020cab80a..0c3eef3d24 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -2319,7 +2319,7 @@ public: wxPen MidiGrid::GetRowGridLinePen(int row) { if ( row % 12 == 7 ) - return wxPen(*wxBLACK, 1, wxSOLID); + return wxPen(*wxBLACK, 1, wxPENSTYLE_SOLID); else return GetDefaultGridLinePen(); } diff --git a/samples/caret/caret.cpp b/samples/caret/caret.cpp index 7de956c71c..70f7e69591 100644 --- a/samples/caret/caret.cpp +++ b/samples/caret/caret.cpp @@ -479,7 +479,7 @@ void MyCanvas::OnChar( wxKeyEvent &event ) wxCaretSuspend cs(this); wxClientDC dc(this); dc.SetFont(m_font); - dc.SetBackgroundMode(wxSOLID); // overwrite old value + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); // overwrite old value dc.DrawText(ch, m_xMargin + m_xCaret * m_widthChar, m_yMargin + m_yCaret * m_heightChar ); diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 011ca273c9..78b92ed447 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -3080,7 +3080,7 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event) void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) ) { wxPaintDC dc(this); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.DrawText( "wxWidgets common dialogs" " test application" diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index fd7e032661..2b266b9231 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -896,7 +896,7 @@ void MyCanvas::DrawText(wxDC& dc) dc.SetFont( *wxSWISS_FONT ); wxString text; - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); for ( int n = -180; n < 180; n += 30 ) { @@ -2197,7 +2197,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) m_yLogicalOrigin = 0; m_xAxisReversed = m_yAxisReversed = false; - m_backgroundMode = wxSOLID; + m_backgroundMode = wxBRUSHSTYLE_SOLID; m_colourForeground = *wxBLACK; m_colourBackground = *wxLIGHT_GREY; m_textureBackground = false; @@ -2463,8 +2463,9 @@ void MyFrame::OnOption(wxCommandEvent& event) #endif // wxUSE_COLOURDLG case Colour_BackgroundMode: - m_backgroundMode = m_backgroundMode == wxSOLID ? wxTRANSPARENT - : wxSOLID; + m_backgroundMode = m_backgroundMode == wxBRUSHSTYLE_SOLID + ? wxBRUSHSTYLE_TRANSPARENT + : wxBRUSHSTYLE_SOLID; break; case Colour_TextureBackgound: diff --git a/samples/erase/erase.cpp b/samples/erase/erase.cpp index 5336bfe155..c48026dc9d 100644 --- a/samples/erase/erase.cpp +++ b/samples/erase/erase.cpp @@ -178,7 +178,7 @@ private: dc.DrawRectangle(GetClientSize()); dc.SetTextForeground(*wxBLUE); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.DrawText(m_message, 0, 2); // Draw some bitmap/icon to ensure transparent bitmaps are indeed @@ -436,7 +436,7 @@ void MyCanvas::OnEraseBackground( wxEraseEvent& event ) } dc.SetTextForeground(*wxRED); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); dc.DrawText("This text is drawn from OnEraseBackground", 60, 160); } diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index bfac9abd3a..682dac26c3 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -139,7 +139,7 @@ void MyApp::Draw(wxDC&dc) // dc.Clear(); dc.SetFont(m_testFont); - // dc.SetBackgroundMode(wxTRANSPARENT); + // dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxLIGHT_GREY_BRUSH); @@ -679,7 +679,7 @@ void MyPrintout::DrawPageTwo() dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250); dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits)); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc->SetBrush(*wxTRANSPARENT_BRUSH); { // GetTextExtent demo: diff --git a/samples/svg/svgtest.cpp b/samples/svg/svgtest.cpp index 26c5f9b323..b6bf13d681 100644 --- a/samples/svg/svgtest.cpp +++ b/samples/svg/svgtest.cpp @@ -342,7 +342,7 @@ void MyPage::OnDraw(wxDC& dc) wP = *wxCYAN_PEN; wP.SetWidth(3); dc.SetPen(wP); - //wxTRANSPARENT)); + //wxBRUSHSTYLE_TRANSPARENT)); dc.SetBrush (wxBrush ("SALMON")); dc.DrawEllipticArc(300, 0,200,100, 0.0,145.0); //same end point diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index b2dc732a66..c0b67db7ae 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -912,7 +912,7 @@ bool wxAuiToolBar::Create(wxWindow* parent, SetExtraStyle(wxWS_EX_PROCESS_IDLE); if (style & wxAUI_TB_HORZ_LAYOUT) SetToolTextOrientation(wxAUI_TBTOOL_TEXT_RIGHT); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); return true; } diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 088f8eecd2..a57599fcb5 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -97,7 +97,7 @@ public: const wxString &name = wxT("frame")) : wxFrame(parent, id, title, pos, size, style | wxFRAME_SHAPED, name) { - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_amount=0; m_maxWidth=0; m_maxHeight=0; diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 09e56194e8..5812e393f3 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -1127,7 +1127,7 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, { // Calculate origin for each line to avoid accumulation of // rounding errors. - if ( m_backgroundMode == wxTRANSPARENT ) + if ( m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT ) m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle )); else m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) ); @@ -1170,7 +1170,7 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) if ( !m_logicalFunctionSupported ) return; - if ( m_backgroundMode == wxTRANSPARENT ) + if ( m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT ) m_graphicContext->DrawText( str, x ,y); else m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush(m_textBackgroundColour) ); diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index 74f105e2a2..54c0698ef4 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -104,9 +104,9 @@ wxPROPERTY( Size,int, SetPointSize, GetPointSize, 12, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) wxPROPERTY( Family, wxFontFamily , SetFamily, GetFamily, (wxFontFamily)wxDEFAULT, \ 0 /*flags*/, wxT("Helpstring"), wxT("group")) // wxFontFamily -wxPROPERTY( Style, wxFontStyle, SetStyle, GetStyle, (wxFontStyle)wxNORMAL, 0 /*flags*/, \ +wxPROPERTY( Style, wxFontStyle, SetStyle, GetStyle, wxFONTSTYLE_NORMAL, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) // wxFontStyle -wxPROPERTY( Weight, wxFontWeight, SetWeight, GetWeight, (wxFontWeight)wxNORMAL, 0 /*flags*/, \ +wxPROPERTY( Weight, wxFontWeight, SetWeight, GetWeight, wxFONTWEIGHT_NORMAL, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) // wxFontWeight wxPROPERTY( Underlined, bool, SetUnderlined, GetUnderlined, false, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) diff --git a/src/common/glcmn.cpp b/src/common/glcmn.cpp index 21f7d54129..03dd583ca1 100644 --- a/src/common/glcmn.cpp +++ b/src/common/glcmn.cpp @@ -76,7 +76,7 @@ wxGLCanvasBase::wxGLCanvasBase() // we always paint background entirely ourselves so prevent wx from erasing // it to avoid flicker - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } bool wxGLCanvasBase::SetCurrent(const wxGLContext& context) const diff --git a/src/dfb/brush.cpp b/src/dfb/brush.cpp index d8ffb6c5a3..ba9f38e3c6 100644 --- a/src/dfb/brush.cpp +++ b/src/dfb/brush.cpp @@ -44,9 +44,9 @@ public: void SetStyle(wxBrushStyle style) { - if ( style != wxSOLID && style != wxTRANSPARENT ) + if ( style != wxBRUSHSTYLE_SOLID && style != wxBRUSHSTYLE_TRANSPARENT ) { - wxFAIL_MSG( wxT("only wxSOLID and wxTRANSPARENT styles are supported") ); + wxFAIL_MSG( wxT("only wxBRUSHSTYLE_SOLID and wxBRUSHSTYLE_TRANSPARENT styles are supported") ); style = wxBRUSHSTYLE_SOLID; } diff --git a/src/dfb/dc.cpp b/src/dfb/dc.cpp index d6141a7602..a65f9bca0b 100644 --- a/src/dfb/dc.cpp +++ b/src/dfb/dc.cpp @@ -135,7 +135,7 @@ void wxDFBDCImpl::Clear() { wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if ( m_backgroundBrush.GetStyle() == wxTRANSPARENT ) + if ( m_backgroundBrush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT ) return; wxColour clr = m_backgroundBrush.GetColour(); @@ -181,7 +181,7 @@ void wxDFBDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if ( m_pen.GetStyle() == wxTRANSPARENT ) + if ( m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT ) return; wxCoord xx1 = XLOG2DEV(x1); @@ -278,7 +278,7 @@ void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h yy = yy - hh; } - if ( m_brush.GetStyle() != wxTRANSPARENT ) + if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT ) { SelectColour(m_brush.GetColour()); m_surface->FillRectangle(xx, yy, ww, hh); @@ -287,7 +287,7 @@ void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h SelectColour(m_pen.GetColour()); } - if ( m_pen.GetStyle() != wxTRANSPARENT ) + if ( m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT ) { m_surface->DrawRectangle(xx, yy, ww, hh); } @@ -343,7 +343,7 @@ void wxDFBDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) CalcBoundingBox(x + w, y + h); // if background mode is solid, DrawText must paint text's background: - if ( m_backgroundMode == wxSOLID ) + if ( m_backgroundMode == wxBRUSHSTYLE_SOLID ) { wxCHECK_RET( m_textBackgroundColour.IsOk(), wxT("invalid background color") ); diff --git a/src/dfb/pen.cpp b/src/dfb/pen.cpp index 02f290da02..cac8a98561 100644 --- a/src/dfb/pen.cpp +++ b/src/dfb/pen.cpp @@ -43,7 +43,7 @@ public: { if ( style != wxPENSTYLE_SOLID && style != wxPENSTYLE_TRANSPARENT ) { - wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" ); + wxFAIL_MSG( "only wxPENSTYLE_SOLID and wxPENSTYLE_TRANSPARENT styles are supported" ); style = wxPENSTYLE_SOLID; } diff --git a/src/generic/buttonbar.cpp b/src/generic/buttonbar.cpp index 38848cd30b..2e4c1c9772 100644 --- a/src/generic/buttonbar.cpp +++ b/src/generic/buttonbar.cpp @@ -500,7 +500,7 @@ void wxButtonToolBar::OnPaint(wxPaintEvent& WXUNUSED(event)) wxPaintDC dc(this); dc.SetFont(GetFont()); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; diff --git a/src/generic/calctrlg.cpp b/src/generic/calctrlg.cpp index 3c5b8ce4e9..b8169ec11c 100644 --- a/src/generic/calctrlg.cpp +++ b/src/generic/calctrlg.cpp @@ -913,7 +913,7 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) // draw column with calendar week nr if ( HasFlag( wxCAL_SHOW_WEEK_NUMBERS ) && IsExposed( 0, y, m_calendarWeekWidth, m_heightRow * 6 )) { - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); dc.DrawRectangle( 0, y, m_calendarWeekWidth, m_heightRow * 6 ); diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 41c3b7fbed..448a58bf5b 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1965,7 +1965,7 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i SetBackgroundColour( *wxWHITE ); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_penRule = wxPen(GetRuleColour()); diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 295c7c7650..9787ed6fc6 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1546,7 +1546,7 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) wxCoord wxPostScriptDCImpl::GetCharWidth() const { - // Chris Breeze: reasonable approximation using wxMODERN/Courier + // Chris Breeze: reasonable approximation using wxFONTFAMILY_MODERN/Courier return (wxCoord) (GetCharHeight() * 72.0 / 120.0); } @@ -1983,7 +1983,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, #if !wxUSE_AFM_FOR_POSTSCRIPT /* Provide a VERY rough estimate (avoid using it). * Produces accurate results for mono-spaced font - * such as Courier (aka wxMODERN) */ + * such as Courier (aka wxFONTFAMILY_MODERN) */ if ( x ) *x = strlen (strbuf) * fontSize * 72.0 / 120.0; @@ -2061,8 +2061,8 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, switch (Family) { - case wxMODERN: - case wxTELETYPE: + case wxFONTFAMILY_MODERN: + case wxFONTFAMILY_TELETYPE: { if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("CourBoO.afm"); else if ((Style != wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("CourBo.afm"); @@ -2070,7 +2070,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, else name = wxT("Cour.afm"); break; } - case wxROMAN: + case wxFONTFAMILY_ROMAN: { if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("TimesBoO.afm"); else if ((Style != wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("TimesBo.afm"); @@ -2078,12 +2078,12 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, else name = wxT("TimesRo.afm"); break; } - case wxSCRIPT: + case wxFONTFAMILY_SCRIPT: { name = wxT("Zapf.afm"); break; } - case wxSWISS: + case wxFONTFAMILY_SWISS: default: { if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("HelvBoO.afm"); diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index 0bcc66593f..d3fa849ad4 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -73,7 +73,7 @@ bool wxHeaderCtrl::Create(wxWindow *parent, // tell the system to not paint the background at all to avoid flicker as // we paint the entire window area in our OnPaint() - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); return true; } diff --git a/src/generic/markuptext.cpp b/src/generic/markuptext.cpp index c883632b9d..e49938ccab 100644 --- a/src/generic/markuptext.cpp +++ b/src/generic/markuptext.cpp @@ -147,7 +147,7 @@ public: { // Setting the background colour is not enough, we must also change // the mode to ensure that it is actually used. - m_dc.SetBackgroundMode(wxSOLID); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); m_dc.SetTextBackground(attr.background); } } @@ -170,7 +170,7 @@ public: // should actually be made transparent and in this case the // actual value of background colour doesn't matter but we also // restore it just in case, see comment in the ctor. - m_dc.SetBackgroundMode(wxTRANSPARENT); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); background = m_origTextBackground; } @@ -260,7 +260,7 @@ public: const wxSize extent = m_dc.GetTextExtent(text); // DrawItemText() ignores background color, so render it ourselves - if ( m_dc.GetBackgroundMode() == wxSOLID ) + if ( m_dc.GetBackgroundMode() == wxBRUSHSTYLE_SOLID) { #if wxUSE_GRAPHICS_CONTEXT // Prefer to use wxGraphicsContext because it supports alpha channel; fall back to wxDC diff --git a/src/generic/renderg.cpp b/src/generic/renderg.cpp index eb5e1442c4..90ee529cdb 100644 --- a/src/generic/renderg.cpp +++ b/src/generic/renderg.cpp @@ -194,7 +194,7 @@ static void DrawSelectedCellFocusRect(wxDC& dc, const wxRect& rect) { // (This code is based on wxRendererGeneric::DrawFocusRect and modified.) - // draw the pixels manually because the "dots" in wxPen with wxDOT style + // draw the pixels manually because the "dots" in wxPen with wxPENSTYLE_DOT style // may be short traits and not really dots // // note that to behave in the same manner as DrawRect(), we must exclude @@ -816,7 +816,7 @@ wxRendererGeneric::DrawItemSelectionRect(wxWindow * WXUNUSED(win), void wxRendererGeneric::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags)) { - // draw the pixels manually because the "dots" in wxPen with wxDOT style + // draw the pixels manually because the "dots" in wxPen with wxPENSTYLE_DOT style // may be short traits and not really dots // // note that to behave in the same manner as DrawRect(), we must exclude diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 26442e4577..e0d5c1900c 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -101,7 +101,7 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id, #if !defined(__WXGTK__) || defined(__WXGTK20__) // don't erase the splitter background, it's pointless as we overwrite it // anyhow - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); #endif return true; diff --git a/src/generic/tabg.cpp b/src/generic/tabg.cpp index 2580a9aece..a2e00b21d4 100644 --- a/src/generic/tabg.cpp +++ b/src/generic/tabg.cpp @@ -203,7 +203,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); wxCoord textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); @@ -474,7 +474,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); long textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 7e05d37586..6d0f120f46 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -1019,7 +1019,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, if (!m_hasFont) SetOwnFont(attr.font); - // this is a misnomer: it's called "dotted pen" but uses (default) wxSOLID + // this is a misnomer: it's called "dotted pen" but uses (default) wxPENSTYLE_SOLID // style because we apparently get performance problems when using dotted // pen for drawing in some ports -- but under MSW it seems to work fine #ifdef __WXMSW__ diff --git a/src/generic/vlbox.cpp b/src/generic/vlbox.cpp index 4aabd378ad..79f03a9bc0 100644 --- a/src/generic/vlbox.cpp +++ b/src/generic/vlbox.cpp @@ -95,7 +95,7 @@ bool wxVListBox::Create(wxWindow *parent, m_colBgSel = wxNullColour; // flicker-free drawing requires this - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); return true; } diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index d533d86efb..57c5b14dbf 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -205,7 +205,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, // get the style's font // TODO: isn't there a way to get a standard gtk 1.2 font? - attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + attr.font = wxFont( 12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); return attr; } diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 1dacb1b416..623f049e72 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -49,8 +49,8 @@ #include "cross.xbm" #define num_hatches 6 -#define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH) -#define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH) +#define IS_15_PIX_HATCH(s) ((s)==wxHATCHSTYLE_CROSSDIAG || (s)==wxHATCHSTYLE_HORIZONTAL || (s)==wxHATCHSTYLE_VERTICAL) +#define IS_16_PIX_HATCH(s) ((s)!=wxHATCHSTYLE_CROSSDIAG && (s)!=wxHATCHSTYLE_HORIZONTAL && (s)!=wxHATCHSTYLE_VERTICAL) static GdkPixmap *hatches[num_hatches]; @@ -453,7 +453,7 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { if (m_window) gdk_draw_line( m_window, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); @@ -467,7 +467,7 @@ void wxWindowDCImpl::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { int w = 0; int h = 0; @@ -525,9 +525,9 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, if (m_window) { - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -547,7 +547,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -561,7 +561,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { gdk_draw_arc( m_window, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); @@ -592,9 +592,9 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC wxCoord start = wxCoord(sa * 64.0); wxCoord end = wxCoord((ea-sa) * 64.0); - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -614,7 +614,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -628,7 +628,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, start, end ); } @@ -640,7 +640,7 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window) + if ((m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) && m_window) gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) ); CalcBoundingBox (x, y); @@ -650,7 +650,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (m_pen.GetStyle() == wxTRANSPARENT) return; + if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return; if (n <= 0) return; @@ -696,13 +696,13 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs gpts[i].y = YLOG2DEV(y); } - if (m_brush.GetStyle() == wxSOLID) + if (m_brush.GetStyle() == wxBRUSHSTYLE_SOLID) { gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); } - else if (m_brush.GetStyle() != wxTRANSPARENT) + else if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -722,7 +722,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -736,7 +736,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { gdk_draw_polygon( m_window, m_penGC, FALSE, gpts, n ); @@ -763,9 +763,9 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo if (m_window) { - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -785,7 +785,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -799,7 +799,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 ); } @@ -836,7 +836,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width // CMB: adjust size if outline is drawn otherwise the result is // 1 pixel too wide and high - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { ww--; hh--; @@ -851,9 +851,9 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width if (dd > hh) dd = hh; rr = dd / 2; - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -888,7 +888,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -912,7 +912,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { gdk_draw_line( m_window, m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); gdk_draw_line( m_window, m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); @@ -945,9 +945,9 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord if (m_window) { - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -967,7 +967,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -981,7 +981,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 ); } @@ -1410,7 +1410,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) wxCoord width = gdk_string_width( font, text.mbc_str() ); wxCoord height = font->ascent + font->descent; - if ( m_backgroundMode == wxSOLID ) + if ( m_backgroundMode == wxBRUSHSTYLE_SOLID ) { gdk_gc_set_foreground( m_textGC, m_textBackgroundColour.GetColor() ); gdk_draw_rectangle( m_window, m_textGC, TRUE, x, y, width, height ); @@ -1686,35 +1686,35 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) GdkLineStyle lineStyle = GDK_LINE_SOLID; switch (m_pen.GetStyle()) { - case wxUSER_DASH: + case wxPENSTYLE_USER_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = m_pen.GetDashCount(); req_dash = (wxGTKDash*)m_pen.GetDash(); break; } - case wxDOT: + case wxPENSTYLE_DOT: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = 2; req_dash = dotted; break; } - case wxLONG_DASH: + case wxPENSTYLE_LONG_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = 2; req_dash = wxCoord_dashed; break; } - case wxSHORT_DASH: + case wxPENSTYLE_SHORT_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = 2; req_dash = short_dashed; break; } - case wxDOT_DASH: + case wxPENSTYLE_DOT_DASH: { // lineStyle = GDK_LINE_DOUBLE_DASH; lineStyle = GDK_LINE_ON_OFF_DASH; @@ -1723,10 +1723,10 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) break; } - case wxTRANSPARENT: - case wxSTIPPLE_MASK_OPAQUE: - case wxSTIPPLE: - case wxSOLID: + case wxPENSTYLE_TRANSPARENT: + case wxPENSTYLE_STIPPLE_MASK_OPAQUE: + case wxPENSTYLE_STIPPLE: + case wxPENSTYLE_SOLID: default: { lineStyle = GDK_LINE_SOLID; @@ -1806,7 +1806,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) gdk_gc_set_fill( m_brushGC, GDK_SOLID ); - if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->IsOk())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) && (m_brush.GetStipple()->IsOk())) { if (m_brush.GetStipple()->GetPixmap()) { @@ -1820,7 +1820,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) } } - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED); gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() ); @@ -1829,7 +1829,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) if (m_brush.IsHatch()) { gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); - int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_brush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; gdk_gc_set_stipple( m_brushGC, hatches[num] ); } } @@ -1857,7 +1857,7 @@ void wxWindowDCImpl::SetBackground( const wxBrush &brush ) gdk_gc_set_fill( m_bgGC, GDK_SOLID ); - if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->IsOk())) + if ((m_backgroundBrush.GetStyle() == wxBRUSHSTYLE_STIPPLE) && (m_backgroundBrush.GetStipple()->IsOk())) { if (m_backgroundBrush.GetStipple()->GetPixmap()) { @@ -1874,7 +1874,7 @@ void wxWindowDCImpl::SetBackground( const wxBrush &brush ) if (m_backgroundBrush.IsHatch()) { gdk_gc_set_fill( m_bgGC, GDK_STIPPLED ); - int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_backgroundBrush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; gdk_gc_set_stipple( m_bgGC, hatches[num] ); } } @@ -1974,10 +1974,10 @@ void wxWindowDCImpl::SetBackgroundMode( int mode ) // CMB 21/7/98: fill style of cross-hatch brushes is affected by // transparent/solid background mode - if (m_brush.GetStyle() != wxSOLID && m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_SOLID && m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { gdk_gc_set_fill( m_brushGC, - (m_backgroundMode == wxTRANSPARENT) ? GDK_STIPPLED : GDK_OPAQUE_STIPPLED); + (m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT) ? GDK_STIPPLED : GDK_OPAQUE_STIPPLED); } } diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index c2460ca128..f0e8993714 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -202,7 +202,7 @@ void wxFontRefData::InitFromNative() m_pointSize = wxDEFAULT_FONT_SIZE; } - // examine the spacing: if the font is monospaced, assume wxTELETYPE + // examine the spacing: if the font is monospaced, assume wxFONTFAMILY_TELETYPE // family for compatibility with the old code which used it instead of // IsFixedWidth() if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index f3e00e58f9..94fbb80bc2 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -347,7 +347,7 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) { if (!gs_objects.m_fontSystem.IsOk()) { - gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + gs_objects.m_fontSystem = wxFont( 12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); } return gs_objects.m_fontSystem; } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index d36a768d0c..fdc2e37a2c 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2918,7 +2918,7 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags void wxWindowGTK::OnInternalIdle() { // Update style if the window was not yet realized - // and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called + // and SetBackgroundStyle(wxBG_STYLE_PAINT) was called if (m_needsStyleChange) { SetBackgroundStyle(GetBackgroundStyle()); @@ -3583,7 +3583,7 @@ void wxWindowGTK::GtkSendPaintEvents() wxEraseEvent erase_event( GetId(), &dc ); erase_event.SetEventObject( this ); - if (!HandleWindowEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM) + if (!HandleWindowEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_PAINT) { if (!g_eraseGC) { @@ -3705,7 +3705,7 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) // apply style change (forceStyle=true so that new style is applied // even if the bg colour changed from valid to wxNullColour) - if (GetBackgroundStyle() != wxBG_STYLE_CUSTOM) + if (GetBackgroundStyle() != wxBG_STYLE_PAINT) ApplyWidgetStyle(true); return true; @@ -3818,7 +3818,7 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) { wxWindowBase::SetBackgroundStyle(style); - if (style == wxBG_STYLE_CUSTOM) + if (style == wxBG_STYLE_PAINT) { GdkWindow *window = NULL; if (m_wxwindow) diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 1768178b65..465bdc60d7 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -400,7 +400,7 @@ static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info, if ( toSelection ) { - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); dc.SetTextForeground(info.GetStyle().GetSelectedTextColour(fg)); dc.SetTextBackground(info.GetStyle().GetSelectedTextBgColour(bg)); dc.SetBackground(info.GetStyle().GetSelectedTextBgColour(bg)); @@ -411,7 +411,7 @@ static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info, dc.SetBackgroundMode(mode); dc.SetTextForeground(fg); dc.SetTextBackground(bg); - if ( mode != wxTRANSPARENT ) + if ( mode != wxBRUSHSTYLE_TRANSPARENT ) dc.SetBackground(bg); } } @@ -1469,23 +1469,23 @@ void wxHtmlColourCell::DrawInvisible(wxDC& dc, if (m_Flags & wxHTML_CLR_BACKGROUND) { state.SetBgColour(m_Colour); - state.SetBgMode(wxSOLID); + state.SetBgMode(wxBRUSHSTYLE_SOLID); const wxColour c = state.GetSelectionState() == wxHTML_SEL_IN ? info.GetStyle().GetSelectedTextBgColour(m_Colour) : m_Colour; dc.SetTextBackground(c); dc.SetBackground(c); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); } if (m_Flags & wxHTML_CLR_TRANSPARENT_BACKGROUND) { state.SetBgColour(m_Colour); - state.SetBgMode(wxTRANSPARENT); + state.SetBgMode(wxBRUSHSTYLE_TRANSPARENT); const wxColour c = state.GetSelectionState() == wxHTML_SEL_IN ? info.GetStyle().GetSelectedTextBgColour(m_Colour) : m_Colour; dc.SetTextBackground(c); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); } } diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index eca5d83869..5befc5879f 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -1134,7 +1134,7 @@ void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) // draw the HTML window contents dc->SetMapMode(wxMM_TEXT); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc->SetLayoutDirection(GetLayoutDirection()); wxHtmlRenderingInfo rinfo; diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index 2ed4e19256..08a052eb8f 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -533,7 +533,7 @@ void wxHtmlPrintout::RenderPage(wxDC *dc, int page) (double)ppiPrinterY / TYPICAL_SCREEN_DPI, (double)ppiPrinterY / (double)ppiScreenY); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); m_Renderer.Render((int) (ppmm_h * m_MarginLeft), (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight), diff --git a/src/html/m_fonts.cpp b/src/html/m_fonts.cpp index 6d039f99ae..35e229de02 100644 --- a/src/html/m_fonts.cpp +++ b/src/html/m_fonts.cpp @@ -140,7 +140,7 @@ TAG_HANDLER_BEGIN(FONT, "FONT" ) m_WParser->SetActualBackgroundMode(oldbackmode); m_WParser->SetActualBackgroundColor(oldbackclr); m_WParser->GetContainer()->InsertCell( - new wxHtmlColourCell(oldbackclr, oldbackmode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); + new wxHtmlColourCell(oldbackclr, oldbackmode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); } return true; diff --git a/src/html/m_links.cpp b/src/html/m_links.cpp index b5a6553ce6..66dbb10a3b 100644 --- a/src/html/m_links.cpp +++ b/src/html/m_links.cpp @@ -110,7 +110,7 @@ TAG_HANDLER_BEGIN(A, "A") m_WParser->SetActualBackgroundMode(oldbackmode); m_WParser->SetActualBackgroundColor(oldbackclr); m_WParser->GetContainer()->InsertCell( - new wxHtmlColourCell(oldbackclr, oldbackmode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); + new wxHtmlColourCell(oldbackclr, oldbackmode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); } return true; diff --git a/src/html/m_span.cpp b/src/html/m_span.cpp index bb9e9facc5..9ef9d196c9 100644 --- a/src/html/m_span.cpp +++ b/src/html/m_span.cpp @@ -69,7 +69,7 @@ TAG_HANDLER_BEGIN(SPAN, "SPAN" ) m_WParser->SetActualBackgroundMode(oldbackmode); m_WParser->SetActualBackgroundColor(oldbackclr); m_WParser->GetContainer()->InsertCell( - new wxHtmlColourCell(oldbackclr, oldbackmode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); + new wxHtmlColourCell(oldbackclr, oldbackmode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); } return true; diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 0ac09fb108..96650b2b37 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -217,7 +217,7 @@ void wxHtmlWinParser::InitParser(const wxString& source) m_ActualBackgroundColor = m_windowInterface ? m_windowInterface->GetHTMLBackgroundColour() : windowColour; - m_ActualBackgroundMode = wxTRANSPARENT; + m_ActualBackgroundMode = wxBRUSHSTYLE_TRANSPARENT; m_Align = wxHTML_ALIGN_LEFT; m_ScriptMode = wxHTML_SCRIPT_NORMAL; m_ScriptBaseline = 0; @@ -248,7 +248,7 @@ void wxHtmlWinParser::InitParser(const wxString& source) new wxHtmlColourCell ( m_ActualBackgroundColor, - m_ActualBackgroundMode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND + m_ActualBackgroundMode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND ) ); @@ -766,7 +766,7 @@ void wxHtmlWinTagHandler::ApplyStyle(const wxHtmlStyleParams &styleParams) if ( wxHtmlTag::ParseAsColour(str, &clr) ) { m_WParser->SetActualBackgroundColor(clr); - m_WParser->SetActualBackgroundMode(wxSOLID); + m_WParser->SetActualBackgroundMode(wxBRUSHSTYLE_SOLID); m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND)); } } diff --git a/src/motif/dc.cpp b/src/motif/dc.cpp index c4ba143e54..908c8f76d1 100644 --- a/src/motif/dc.cpp +++ b/src/motif/dc.cpp @@ -29,7 +29,7 @@ wxMotifDCImpl::wxMotifDCImpl(wxDC *owner) { m_ok = false; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxBRUSHSTYLE_TRANSPARENT; } void wxMotifDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index a85f36bfc2..edc154f80a 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -83,7 +83,7 @@ wxIMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl); wxIMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxWindowDCImpl); wxIMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxMotifDCImpl); -#define IS_HATCH(s) ((s)>=wxFIRST_HATCH && (s)<=wxLAST_HATCH) +#define IS_HATCH(s) ((s)>=wxHATCHSTYLE_FIRST && (s)<=wxHATCHSTYLE_LAST) // FIXME: left over after removal of wxDC::GetOptimization() #define GET_OPTIMIZATION false @@ -197,7 +197,7 @@ wxWindowDCImpl::wxWindowDCImpl(wxDC *owner, wxWindow *window) m_backgroundPixel = gcvalues.background; - SetBackground(wxBrush(m_window->GetBackgroundColour(), wxSOLID)); + SetBackground(wxBrush(m_window->GetBackgroundColour(), wxBRUSHSTYLE_SOLID)); } wxWindowDCImpl::~wxWindowDCImpl() @@ -346,7 +346,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, while (alpha2 > 360 * 64) alpha2 -= 360 * 64; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) (GC) m_gc, @@ -358,7 +358,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -393,7 +393,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC if (end>start) end-=start; else end+=360*64-start; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { m_autoSetting = true; // must be reset @@ -405,7 +405,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end); } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -436,7 +436,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset { wxCHECK_RET( IsOk(), "invalid dc" ); - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -487,7 +487,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], xpoints2[i].x = xpoints2[0].x; xpoints2[i].y = xpoints2[0].y; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XSetFillRule ((Display*) m_display, (GC) m_gc, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule); @@ -502,7 +502,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], } } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -533,7 +533,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo if (wd < 0) { wd = - wd; xd = xd - wd; } if (hd < 0) { hd = - hd; yd = yd - hd; } - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wfd, hfd); @@ -544,7 +544,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo wfd, hfd); } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -589,7 +589,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width // CMB: adjust size if outline is drawn otherwise the result is // 1 pixel too wide and high - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { wd--; hd--; @@ -611,7 +611,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width int rw_d2 = rd2 * 2; int rh_d2 = rw_d2; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); @@ -661,7 +661,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width } } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { SetPen (m_pen); XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd, @@ -745,7 +745,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord wd = XLOG2DEVREL(width) ; hd = YLOG2DEVREL(height) ; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle); @@ -756,7 +756,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord YLOG2DEVREL (height) - WX_GC_CF, 0, angle); } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -1048,7 +1048,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // First draw a rectangle representing the text background, if a text // background is specified - if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxTRANSPARENT)) + if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxBRUSHSTYLE_TRANSPARENT)) { wxColour oldPenColour = m_currentColour; m_currentColour = m_textBackgroundColour; @@ -1243,7 +1243,7 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord { bool textPixel = image.GetRed(sx, sy) == 0; - if (!textPixel && m_backgroundMode != wxSOLID) + if (!textPixel && m_backgroundMode != wxBRUSHSTYLE_SOLID) continue; wxCoord ox = (wxCoord) (x1 + rx), @@ -1510,7 +1510,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) m_currentPenDashCount = m_pen.GetDashCount(); m_currentPenDash = (wxX11Dash*)m_pen.GetDash(); - if (m_currentStyle == wxSTIPPLE) + if (m_currentStyle == wxPENSTYLE_STIPPLE) m_currentStipple = * m_pen.GetStipple (); bool sameStyle = (oldStyle == m_currentStyle && @@ -1548,34 +1548,34 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) switch (m_pen.GetStyle ()) { - case wxUSER_DASH: + case wxPENSTYLE_USER_DASH: req_nb_dash = m_currentPenDashCount; req_dash = m_currentPenDash; style = LineOnOffDash; break; - case wxDOT: + case wxPENSTYLE_DOT: req_nb_dash = 2; req_dash = dotted; style = LineOnOffDash; break; - case wxSHORT_DASH: + case wxPENSTYLE_SHORT_DASH: req_nb_dash = 2; req_dash = short_dashed; style = LineOnOffDash; break; - case wxLONG_DASH: + case wxPENSTYLE_LONG_DASH: req_nb_dash = 2; req_dash = long_dashed; style = LineOnOffDash; break; - case wxDOT_DASH: + case wxPENSTYLE_DOT_DASH: req_nb_dash = 4; req_dash = dotted_dashed; style = LineOnOffDash; break; - case wxSTIPPLE: - case wxSOLID: - case wxTRANSPARENT: + case wxPENSTYLE_STIPPLE: + case wxPENSTYLE_SOLID: + case wxPENSTYLE_TRANSPARENT: default: style = LineSolid; req_dash = NULL; @@ -1648,42 +1648,42 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) switch (m_currentFill) { - case wxBDIAGONAL_HATCH: + case wxHATCHSTYLE_BDIAGONAL: if (bdiag == (Pixmap) 0) bdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(bdiag_bits), bdiag_width, bdiag_height); myStipple = bdiag; break; - case wxFDIAGONAL_HATCH: + case wxHATCHSTYLE_FDIAGONAL: if (fdiag == (Pixmap) 0) fdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(fdiag_bits), fdiag_width, fdiag_height); myStipple = fdiag; break; - case wxCROSS_HATCH: + case wxHATCHSTYLE_CROSS: if (cross == (Pixmap) 0) cross = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(cross_bits), cross_width, cross_height); myStipple = cross; break; - case wxHORIZONTAL_HATCH: + case wxHATCHSTYLE_HORIZONTAL: if (horiz == (Pixmap) 0) horiz = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(horiz_bits), horiz_width, horiz_height); myStipple = horiz; break; - case wxVERTICAL_HATCH: + case wxHATCHSTYLE_VERTICAL: if (verti == (Pixmap) 0) verti = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(verti_bits), verti_width, verti_height); myStipple = verti; break; - case wxCROSSDIAG_HATCH: + case wxHATCHSTYLE_CROSSDIAG: default: if (cdiag == (Pixmap) 0) cdiag = XCreateBitmapFromData ((Display*) m_display, @@ -1697,7 +1697,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) if (m_window && m_window->GetBackingPixmap()) XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple); } - else if (m_currentStyle == wxSTIPPLE && m_currentStipple.IsOk() + else if (m_currentStyle == wxPENSTYLE_STIPPLE && m_currentStipple.IsOk() && ((!m_currentStipple.IsSameAs(oldStipple)) || !GET_OPTIMIZATION)) { XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetDrawable()); @@ -1710,7 +1710,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) { int fill_style; - if (m_currentFill == wxSTIPPLE) + if (m_currentFill == wxBRUSHSTYLE_STIPPLE) fill_style = FillStippled; else if (IS_HATCH (m_currentFill)) fill_style = FillStippled; @@ -1726,7 +1726,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) || ((m_logicalFunction == wxXOR) || (m_autoSetting & 0x2))) { WXPixel pixel = -1; - if (m_pen.GetStyle () == wxTRANSPARENT) + if (m_pen.GetStyle () == wxPENSTYLE_TRANSPARENT) pixel = m_backgroundPixel; else { @@ -1751,7 +1751,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) m_brush = brush; - if (!m_brush.IsOk() || m_brush.GetStyle () == wxTRANSPARENT) + if (!m_brush.IsOk() || m_brush.GetStyle () == wxBRUSHSTYLE_TRANSPARENT) return; int oldFill = m_currentFill; @@ -1760,7 +1760,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) m_autoSetting |= 0x1; m_currentFill = m_brush.GetStyle (); - if (m_currentFill == wxSTIPPLE) + if (m_currentFill == wxBRUSHSTYLE_STIPPLE) m_currentStipple = * m_brush.GetStipple (); wxColour oldBrushColour(m_currentColour); @@ -1778,17 +1778,17 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) { switch (brush.GetStyle ()) { - case wxTRANSPARENT: + case wxBRUSHSTYLE_TRANSPARENT: break; - case wxSTIPPLE: + case wxBRUSHSTYLE_STIPPLE: stippleDepth = m_currentStipple.GetDepth(); // fall through! - case wxBDIAGONAL_HATCH: - case wxCROSSDIAG_HATCH: - case wxFDIAGONAL_HATCH: - case wxCROSS_HATCH: - case wxHORIZONTAL_HATCH: - case wxVERTICAL_HATCH: + case wxBRUSHSTYLE_BDIAGONAL_HATCH: + case wxBRUSHSTYLE_CROSSDIAG_HATCH: + case wxBRUSHSTYLE_FDIAGONAL_HATCH: + case wxBRUSHSTYLE_CROSS_HATCH: + case wxBRUSHSTYLE_HORIZONTAL_HATCH: + case wxBRUSHSTYLE_VERTICAL_HATCH: { if (stippleDepth == -1) stippleDepth = 1; @@ -1796,7 +1796,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) // determine whether fill style should be solid or // transparent int style = stippleDepth == 1 ? - (m_backgroundMode == wxSOLID ? + (m_backgroundMode == wxBRUSHSTYLE_SOLID ? FillOpaqueStippled : FillStippled) : FillTiled; XSetFillStyle ((Display*) m_display, (GC) m_gc, style); @@ -1804,7 +1804,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, style); } break; - case wxSOLID: + case wxBRUSHSTYLE_SOLID: default: XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid); if (m_window && m_window->GetBackingPixmap()) @@ -1819,42 +1819,42 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) switch (m_currentFill) { - case wxBDIAGONAL_HATCH: + case wxHATCHSTYLE_BDIAGONAL: if (bdiag == (Pixmap) 0) bdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(bdiag_bits), bdiag_width, bdiag_height); myStipple = bdiag; break; - case wxFDIAGONAL_HATCH: + case wxHATCHSTYLE_FDIAGONAL: if (fdiag == (Pixmap) 0) fdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(fdiag_bits), fdiag_width, fdiag_height); myStipple = fdiag; break; - case wxCROSS_HATCH: + case wxHATCHSTYLE_CROSS: if (cross == (Pixmap) 0) cross = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(cross_bits), cross_width, cross_height); myStipple = cross; break; - case wxHORIZONTAL_HATCH: + case wxHATCHSTYLE_HORIZONTAL: if (horiz == (Pixmap) 0) horiz = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(horiz_bits), horiz_width, horiz_height); myStipple = horiz; break; - case wxVERTICAL_HATCH: + case wxHATCHSTYLE_VERTICAL: if (verti == (Pixmap) 0) verti = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(verti_bits), verti_width, verti_height); myStipple = verti; break; - case wxCROSSDIAG_HATCH: + case wxHATCHSTYLE_CROSSDIAG: default: if (cdiag == (Pixmap) 0) cdiag = XCreateBitmapFromData ((Display*) m_display, @@ -1870,7 +1870,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) } // X can forget the stipple value when resizing a window (apparently) // so always set the stipple. - else if (m_currentFill != wxSOLID && m_currentFill != wxTRANSPARENT && + else if (m_currentFill != wxBRUSHSTYLE_SOLID && m_currentFill != wxBRUSHSTYLE_TRANSPARENT && m_currentStipple.IsOk()) // && m_currentStipple != oldStipple) { if (m_currentStipple.GetDepth() == 1) diff --git a/src/motif/settings.cpp b/src/motif/settings.cpp index 04f2b66dc1..11fd4e7098 100644 --- a/src/motif/settings.cpp +++ b/src/motif/settings.cpp @@ -179,7 +179,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) { case wxSYS_SYSTEM_FIXED_FONT: { - font = wxFont(pointSize, wxMODERN, wxNORMAL, wxNORMAL, false); + font = wxFont(pointSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false); break; } case wxSYS_DEVICE_DEFAULT_FONT: @@ -187,7 +187,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) case wxSYS_DEFAULT_GUI_FONT: default: { - font = wxFont(pointSize, wxSWISS, wxNORMAL, wxNORMAL, false); + font = wxFont(pointSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false); break; } } diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index 480faad86e..210644e9ff 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -629,7 +629,7 @@ wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, const wxColour& colour) srcDC.SelectObjectAsSource(bitmap); destDC.SelectObject(newBitmap); - wxBrush brush(colour, wxSOLID); + wxBrush brush(colour, wxBRUSHSTYLE_SOLID); destDC.SetBackground(brush); destDC.Clear(); destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), diff --git a/src/motif/window.cpp b/src/motif/window.cpp index c29f053997..fe91644faf 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -886,7 +886,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) XCopyArea(display, window, window, gc, x1, y1, w1, h1, x2, y2); dcimpl->SetAutoSetting(true); - wxBrush brush(GetBackgroundColour(), wxSOLID); + wxBrush brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID); dc.SetBrush(brush); // FIXME: needed? wxWindowList::compatibility_iterator cnode = m_children.GetFirst(); @@ -1537,7 +1537,7 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect) if (eraseBack) { wxClientDC dc(this); - wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID); + wxBrush backgroundBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID); dc.SetBackground(backgroundBrush); wxClientDCImpl * const diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 41ada622d9..0c874ae457 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -390,7 +390,7 @@ HDC CreateCompatibleDCWithLayout(HDC hdc); // ---------------------------------------------------------------------------- // instead of duplicating the same code which sets and then restores text -// colours in each wxDC method working with wxSTIPPLE_MASK_OPAQUE brushes, +// colours in each wxDC method working with wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE brushes, // encapsulate this in a small helper class // wxBrushAttrsSetter: changes the text colours in the ctor if required and @@ -819,7 +819,7 @@ void wxMSWDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord r = (wxCoord)sqrt(dx*dx + dy*dy); - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // treat the special case of full circle separately if ( x1 == x2 && y1 == y2 ) @@ -898,7 +898,7 @@ void wxMSWDCImpl::DoDrawPolygon(int n, wxCoord yoffset, wxPolygonFillMode fillStyle) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) @@ -937,7 +937,7 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, wxCoord yoffset, wxPolygonFillMode fillStyle) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling int i, cnt; for (i = cnt = 0; i < n; i++) cnt += count[i]; @@ -998,7 +998,7 @@ void wxMSWDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wx void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling wxCoord x2 = x + width; wxCoord y2 = y + height; @@ -1031,7 +1031,7 @@ void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // Now, a negative radius value is interpreted to mean // 'the proportion of the smallest X or Y dimension' @@ -1063,7 +1063,7 @@ void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wx void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // +1 below makes the ellipse more similar to other platforms. // In particular, DoDrawEllipse(x,y,1,1) should draw one point. @@ -1178,7 +1178,7 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) // Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling wxCoord x2 = x + w; wxCoord y2 = y + h; diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index d19e6acc16..c398b2c162 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -162,7 +162,7 @@ static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoo { wxBrush brush(dc.GetBrush()); wxPen pen(dc.GetPen()); - if (brush.IsOk() && brush.GetStyle() != wxTRANSPARENT) + if (brush.IsOk() && brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ; if (hBrush) @@ -175,7 +175,7 @@ static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoo } } width --; height --; - if (pen.IsOk() && pen.GetStyle() != wxTRANSPARENT) + if (pen.IsOk() && pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { dc.DrawLine(x, y, x + width, y); dc.DrawLine(x, y, x, y + height); @@ -192,8 +192,8 @@ void wxMemoryDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoor // (visible with e.g. 70x70 rectangle on a memory DC; see Drawing sample) #if wxUSE_MEMORY_DC_DRAW_RECTANGLE if (m_brush.IsOk() && m_pen.IsOk() && - (m_brush.GetStyle() == wxSOLID || m_brush.GetStyle() == wxTRANSPARENT) && - (m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT) && + (m_brush.GetStyle() == wxBRUSHSTYLE_SOLID || m_brush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT) && + (m_pen.GetStyle() == wxPENSTYLE_SOLID || m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) && (GetLogicalFunction() == wxCOPY)) { wxDrawRectangle(* this, x, y, width, height); diff --git a/src/msw/mediactrl_am.cpp b/src/msw/mediactrl_am.cpp index 5379eda8af..4a15fc7fc5 100644 --- a/src/msw/mediactrl_am.cpp +++ b/src/msw/mediactrl_am.cpp @@ -1083,7 +1083,7 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window so that resizing is a // bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // success return true; diff --git a/src/msw/mediactrl_wmp10.cpp b/src/msw/mediactrl_wmp10.cpp index 955303ca58..c220a5a6fb 100644 --- a/src/msw/mediactrl_wmp10.cpp +++ b/src/msw/mediactrl_wmp10.cpp @@ -868,7 +868,7 @@ bool wxWMP10MediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window so that resizing is a // bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // success return true; diff --git a/src/osx/carbon/dcprint.cpp b/src/osx/carbon/dcprint.cpp index e3346689b9..9c12d4b688 100644 --- a/src/osx/carbon/dcprint.cpp +++ b/src/osx/carbon/dcprint.cpp @@ -366,7 +366,7 @@ void wxPrinterDCImpl::StartPage() m_logicalFunction = wxCOPY; // m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxBRUSHSTYLE_TRANSPARENT; m_textForegroundColour = *wxBLACK; m_textBackgroundColour = *wxWHITE; diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index e231531450..6ff597cd02 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -228,7 +228,7 @@ public : { switch ( m_hatch ) { - case wxBDIAGONAL_HATCH : + case wxHATCHSTYLE_BDIAGONAL : { CGPoint pts[] = { @@ -238,7 +238,7 @@ public : } break; - case wxCROSSDIAG_HATCH : + case wxHATCHSTYLE_CROSSDIAG : { CGPoint pts[] = { @@ -249,7 +249,7 @@ public : } break; - case wxFDIAGONAL_HATCH : + case wxHATCHSTYLE_FDIAGONAL : { CGPoint pts[] = { @@ -259,7 +259,7 @@ public : } break; - case wxCROSS_HATCH : + case wxHATCHSTYLE_CROSS : { CGPoint pts[] = { @@ -270,7 +270,7 @@ public : } break; - case wxHORIZONTAL_HATCH : + case wxHATCHSTYLE_HORIZONTAL : { CGPoint pts[] = { @@ -280,7 +280,7 @@ public : } break; - case wxVERTICAL_HATCH : + case wxHATCHSTYLE_VERTICAL : { CGPoint pts[] = { diff --git a/src/osx/carbon/statbrma.cpp b/src/osx/carbon/statbrma.cpp index 7f996df201..09b872d342 100644 --- a/src/osx/carbon/statbrma.cpp +++ b/src/osx/carbon/statbrma.cpp @@ -222,7 +222,7 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event)) if ( GetFont().IsOk() ) dc.SetFont(GetFont()); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); // compute char height only once for all panes: int textHeight = dc.GetCharHeight(); diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index 99ec7ed02f..fce63e54bd 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1543,7 +1543,7 @@ public: m_state = 0; m_boxHeight = 12; - SetBackgroundStyle( wxBG_STYLE_CUSTOM ); + SetBackgroundStyle( wxBG_STYLE_PAINT ); } virtual ~wxSimpleCheckBox(); diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index e46c2183e0..87b3eef99f 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -482,7 +482,7 @@ void wxPropertyGrid::Init2() RegainColours(); // This helps with flicker - SetBackgroundStyle( wxBG_STYLE_CUSTOM ); + SetBackgroundStyle( wxBG_STYLE_PAINT ); // Rely on native double-buffering by default. #if wxALWAYS_NATIVE_DOUBLE_BUFFER diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index ffa67458d1..6fb5ed0e5a 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -669,7 +669,7 @@ void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) QPainter::CompositionMode savedOp = m_qtPainter->compositionMode(); m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver ); - if (m_backgroundMode == wxSOLID) + if (m_backgroundMode == wxBRUSHSTYLE_SOLID) { m_qtPainter->setBackgroundMode(Qt::OpaqueMode); @@ -698,7 +698,7 @@ void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) void wxQtDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { - if (m_backgroundMode == wxSOLID) + if (m_backgroundMode == wxBRUSHSTYLE_SOLID) m_qtPainter->setBackgroundMode(Qt::OpaqueMode); //Move and rotate (reverse angle direction in Qt and wx) @@ -712,7 +712,7 @@ void wxQtDCImpl::DoDrawRotatedText(const wxString& text, QPainter::CompositionMode savedOp = m_qtPainter->compositionMode(); m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver ); - if (m_backgroundMode == wxSOLID) + if (m_backgroundMode == wxBRUSHSTYLE_SOLID) { m_qtPainter->setBackgroundMode(Qt::OpaqueMode); diff --git a/src/ribbon/art_aui.cpp b/src/ribbon/art_aui.cpp index 83fb98d6e6..ab8993ae51 100644 --- a/src/ribbon/art_aui.cpp +++ b/src/ribbon/art_aui.cpp @@ -471,7 +471,7 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc, if(!label.IsEmpty()) { dc.SetTextForeground(m_tab_label_colour); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); int offset = 0; if(icon.IsOk()) diff --git a/src/ribbon/art_msw.cpp b/src/ribbon/art_msw.cpp index f2a85811cd..07b4114b59 100644 --- a/src/ribbon/art_msw.cpp +++ b/src/ribbon/art_msw.cpp @@ -1373,7 +1373,7 @@ void wxRibbonMSWArtProvider::DrawTab( { dc.SetFont(m_tab_label_font); dc.SetTextForeground(m_tab_label_colour); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); int text_height; int text_width; diff --git a/src/ribbon/bar.cpp b/src/ribbon/bar.cpp index 271aa8c46b..9804ec19d7 100644 --- a/src/ribbon/bar.cpp +++ b/src/ribbon/bar.cpp @@ -792,7 +792,7 @@ void wxRibbonBar::CommonInit(long style) { SetArtProvider(new wxRibbonDefaultArtProvider); } - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_toggle_button_hovered = false; m_bar_hovered = false; diff --git a/src/ribbon/buttonbar.cpp b/src/ribbon/buttonbar.cpp index 5be028a710..b0976c1750 100644 --- a/src/ribbon/buttonbar.cpp +++ b/src/ribbon/buttonbar.cpp @@ -895,7 +895,7 @@ void wxRibbonButtonBar::CommonInit(long WXUNUSED(style)) m_lock_active_state = false; m_show_tooltips_for_disabled = false; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } void wxRibbonButtonBar::SetShowToolTipsForDisabled(bool show) diff --git a/src/ribbon/gallery.cpp b/src/ribbon/gallery.cpp index b9ac96123d..29f39ef711 100644 --- a/src/ribbon/gallery.cpp +++ b/src/ribbon/gallery.cpp @@ -135,7 +135,7 @@ void wxRibbonGallery::CommonInit(long WXUNUSED(style)) m_extension_button_state = wxRIBBON_GALLERY_BUTTON_NORMAL; m_hovered = false; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } void wxRibbonGallery::OnMouseEnter(wxMouseEvent& evt) diff --git a/src/ribbon/page.cpp b/src/ribbon/page.cpp index f993ed4faf..93b89c4e5b 100644 --- a/src/ribbon/page.cpp +++ b/src/ribbon/page.cpp @@ -82,7 +82,7 @@ wxRibbonPageScrollButton::wxRibbonPageScrollButton(wxRibbonPage* sibling, const wxSize& size, long style) : wxRibbonControl(sibling->GetParent(), id, pos, size, wxBORDER_NONE) { - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_sibling = sibling; m_flags = (style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | wxRIBBON_SCROLL_BTN_FOR_PAGE; } @@ -207,7 +207,7 @@ void wxRibbonPage::CommonInit(const wxString& label, const wxBitmap& icon) m_scroll_amount = 0; m_scroll_buttons_visible = false; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); wxDynamicCast(GetParent(), wxRibbonBar)->AddPage(this); } diff --git a/src/ribbon/panel.cpp b/src/ribbon/panel.cpp index 6964788a35..dc97dac68c 100644 --- a/src/ribbon/panel.cpp +++ b/src/ribbon/panel.cpp @@ -135,7 +135,7 @@ void wxRibbonPanel::CommonInit(const wxString& label, const wxBitmap& icon, long } SetAutoLayout(true); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); SetMinSize(wxSize(20, 20)); } diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index 80cd8311a9..43e0490e62 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -113,7 +113,7 @@ void wxRibbonToolBar::CommonInit(long WXUNUSED(style)) m_nrows_max = 1; m_sizes = new wxSize[1]; m_sizes[0] = wxSize(0, 0); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } wxRibbonToolBar::~wxRibbonToolBar() diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index c47cbca289..7cfbe3effc 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -9657,7 +9657,7 @@ bool wxRichTextFieldTypeStandard::Draw(wxRichTextField* obj, wxDC& dc, wxRichTex int w, h, maxDescent; dc.SetFont(m_font); dc.GetTextExtent(m_label, & w, &h, & maxDescent); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetTextForeground(textColour); int x = clientArea.x + (clientArea.width - w)/2; diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 0fb71e4cad..b0aab5b388 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -283,7 +283,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va SetDefaultStyle(defaultAttributes); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); GetBuffer().Reset(); GetBuffer().SetRichTextCtrl(this); diff --git a/src/richtext/richtextsymboldlg.cpp b/src/richtext/richtextsymboldlg.cpp index 57512df37a..d500929d31 100644 --- a/src/richtext/richtextsymboldlg.cpp +++ b/src/richtext/richtextsymboldlg.cpp @@ -797,7 +797,7 @@ bool wxSymbolListCtrl::Create(wxWindow *parent, m_colBgSel = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); // flicker-free drawing requires this - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); SetFont(*wxNORMAL_FONT); diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index dc65fcedf9..12f6c593b7 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -117,7 +117,7 @@ public: #endif m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord) { - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); SetName("wxSTCCallTip"); } diff --git a/src/univ/ctrlrend.cpp b/src/univ/ctrlrend.cpp index c8e828edfd..1ec57ad804 100644 --- a/src/univ/ctrlrend.cpp +++ b/src/univ/ctrlrend.cpp @@ -68,7 +68,7 @@ wxControlRenderer::wxControlRenderer(wxWindow *window, void wxControlRenderer::DrawLabel() { - m_dc.SetBackgroundMode(wxTRANSPARENT); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); m_dc.SetFont(m_window->GetFont()); m_dc.SetTextForeground(m_window->GetForegroundColour()); @@ -89,7 +89,7 @@ void wxControlRenderer::DrawLabel() void wxControlRenderer::DrawButtonLabel(const wxBitmap& bitmap, wxCoord marginX, wxCoord marginY) { - m_dc.SetBackgroundMode(wxTRANSPARENT); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); m_dc.SetFont(m_window->GetFont()); m_dc.SetTextForeground(m_window->GetForegroundColour()); diff --git a/src/univ/notebook.cpp b/src/univ/notebook.cpp index 143b8ec82c..b755a5b5a8 100644 --- a/src/univ/notebook.cpp +++ b/src/univ/notebook.cpp @@ -475,7 +475,7 @@ void wxNotebook::DoDrawTab(wxDC& dc, const wxRect& rect, size_t n) bmp.Create(w, h); wxMemoryDC dc; dc.SelectObject(bmp); - dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); + dc.SetBackground(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID)); GetImageList()->Draw(image, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL, true); dc.SelectObject(wxNullBitmap); #else diff --git a/src/univ/stdrend.cpp b/src/univ/stdrend.cpp index d434aac752..33db222a99 100644 --- a/src/univ/stdrend.cpp +++ b/src/univ/stdrend.cpp @@ -199,7 +199,7 @@ void wxStdRenderer::DrawButtonSurface(wxDC& dc, void wxStdRenderer::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags)) { - // draw the pixels manually because the "dots" in wxPen with wxDOT style + // draw the pixels manually because the "dots" in wxPen with wxPENSTYLE_DOT style // may be short traits and not really dots // // note that to behave in the same manner as DrawRect(), we must exclude @@ -774,13 +774,13 @@ void wxStdRenderer::DrawTextLine(wxDC& dc, colBg = dc.GetTextBackground(); dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT)); dc.SetTextBackground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT)); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); dc.DrawText(s, x, rect.y); dc.GetTextExtent(s, &width, NULL); x += width; - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetTextBackground(colBg); dc.SetTextForeground(colFg); } diff --git a/src/univ/themes/mono.cpp b/src/univ/themes/mono.cpp index 0e826fa792..d69fb99941 100644 --- a/src/univ/themes/mono.cpp +++ b/src/univ/themes/mono.cpp @@ -1060,7 +1060,7 @@ void wxMonoRenderer::DrawScrollbarThumb(wxDC& dc, { DrawSolidRect(dc, wxMONO_BG_COL, rect); - // manually draw stipple pattern (wxDFB doesn't implement the wxSTIPPLE + // manually draw stipple pattern (wxDFB doesn't implement the wxBRUSHSTYLE_STIPPLE // brush style): dc.SetPen(m_penFg); for ( wxCoord y = rect.GetTop(); y <= rect.GetBottom(); y++ ) diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 7c26e23ca0..b1ac5be86d 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -1317,11 +1317,11 @@ static wxNativeFont wxLoadQueryFont(float pointSize, logFont.lfCharSet = MWLF_CHARSET_DEFAULT; // TODO: select appropriate one logFont.lfOutPrecision = MWLF_TYPE_DEFAULT; logFont.lfClipPrecision = 0; // Not used - logFont.lfRoman = (family == wxROMAN ? 1 : 0) ; - logFont.lfSerif = (family == wxSWISS ? 0 : 1) ; + logFont.lfRoman = (family == wxFONTFAMILY_ROMAN ? 1 : 0) ; + logFont.lfSerif = (family == wxFONTFAMILY_SWISS ? 0 : 1) ; logFont.lfSansSerif = !logFont.lfSerif ; - logFont.lfModern = (family == wxMODERN ? 1 : 0) ; - logFont.lfProportional = (family == wxTELETYPE ? 0 : 1) ; + logFont.lfModern = (family == wxFONTFAMILY_MODERN ? 1 : 0) ; + logFont.lfProportional = (family == wxFONTFAMILY_TELETYPE ? 0 : 1) ; logFont.lfOblique = 0; logFont.lfSmallCaps = 0; logFont.lfPitch = 0; // 0 = default diff --git a/src/unix/mediactrl.cpp b/src/unix/mediactrl.cpp index 1e5bca9bdc..3c55b1ae33 100644 --- a/src/unix/mediactrl.cpp +++ b/src/unix/mediactrl.cpp @@ -1050,7 +1050,7 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window // so that resizing is a bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // Create our playbin object m_playbin = gst_element_factory_make ("playbin", "play"); diff --git a/src/unix/mediactrl_gstplayer.cpp b/src/unix/mediactrl_gstplayer.cpp index 235bdbc721..6566dd4010 100644 --- a/src/unix/mediactrl_gstplayer.cpp +++ b/src/unix/mediactrl_gstplayer.cpp @@ -309,7 +309,7 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window // so that resizing is a bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // Tell gstreamer to play in our window gpointer window_handle = NULL; diff --git a/src/x11/dc.cpp b/src/x11/dc.cpp index b278aa7ca8..888f15eb58 100644 --- a/src/x11/dc.cpp +++ b/src/x11/dc.cpp @@ -33,7 +33,7 @@ wxX11DCImpl::wxX11DCImpl( wxDC *owner ) : m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxBRUSHSTYLE_TRANSPARENT; } void wxX11DCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 92dd10d9d4..db1837fca9 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -1606,7 +1606,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // First draw a rectangle representing the text background, if a text // background is specified - if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxTRANSPARENT)) + if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxBRUSHSTYLE_TRANSPARENT)) { // Since X draws from the baseline of the text, must add the text height int cx = 0; @@ -1907,35 +1907,35 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) int lineStyle = LineSolid; switch (m_pen.GetStyle()) { - case wxUSER_DASH: + case wxPENSTYLE_USER_DASH: { lineStyle = LineOnOffDash; req_nb_dash = m_pen.GetDashCount(); req_dash = (wxX11Dash*)m_pen.GetDash(); break; } - case wxDOT: + case wxPENSTYLE_DOT: { lineStyle = LineOnOffDash; req_nb_dash = 2; req_dash = dotted; break; } - case wxLONG_DASH: + case wxPENSTYLE_LONG_DASH: { lineStyle = LineOnOffDash; req_nb_dash = 2; req_dash = long_dashed; break; } - case wxSHORT_DASH: + case wxPENSTYLE_SHORT_DASH: { lineStyle = LineOnOffDash; req_nb_dash = 2; req_dash = short_dashed; break; } - case wxDOT_DASH: + case wxPENSTYLE_DOT_DASH: { // lineStyle = LineDoubleDash; lineStyle = LineOnOffDash; @@ -1944,10 +1944,10 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) break; } - case wxTRANSPARENT: - case wxSTIPPLE_MASK_OPAQUE: - case wxSTIPPLE: - case wxSOLID: + case wxPENSTYLE_TRANSPARENT: + case wxPENSTYLE_STIPPLE_MASK_OPAQUE: + case wxPENSTYLE_STIPPLE: + case wxPENSTYLE_SOLID: default: { lineStyle = LineSolid; @@ -2033,7 +2033,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) if (m_brush.IsHatch()) { XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillStippled ); - int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_brush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; XSetStipple( (Display*) m_display, (GC) m_brushGC, hatches[num] ); } } @@ -2078,7 +2078,7 @@ void wxWindowDCImpl::SetBackground( const wxBrush &brush ) if (m_backgroundBrush.IsHatch()) { XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillStippled ); - int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_backgroundBrush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; XSetStipple( (Display*) m_display, (GC) m_bgGC, hatches[num] ); } } @@ -2203,7 +2203,7 @@ void wxWindowDCImpl::SetBackgroundMode( int mode ) m_backgroundMode = mode; #if wxUSE_NANOX - GrSetGCUseBackground((GC) m_textGC, mode == wxTRANSPARENT ? FALSE : TRUE); + GrSetGCUseBackground((GC) m_textGC, mode == wxBRUSHSTYLE_TRANSPARENT ? FALSE : TRUE); #endif if (!m_x11window) return; @@ -2214,7 +2214,7 @@ void wxWindowDCImpl::SetBackgroundMode( int mode ) if (m_brush.GetStyle() != wxBRUSHSTYLE_SOLID && m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { XSetFillStyle( (Display*) m_display, (GC) m_brushGC, - (m_backgroundMode == wxTRANSPARENT) ? FillStippled : FillOpaqueStippled ); + (m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT) ? FillStippled : FillOpaqueStippled ); } } diff --git a/src/x11/font.cpp b/src/x11/font.cpp index 2662d271b7..8c229a6d3c 100644 --- a/src/x11/font.cpp +++ b/src/x11/font.cpp @@ -316,7 +316,7 @@ void wxFontRefData::InitFromNative() m_pointSize = wxDEFAULT_FONT_SIZE; } - // examine the spacing: if the font is monospaced, assume wxTELETYPE + // examine the spacing: if the font is monospaced, assume wxFONTFAMILY_TELETYPE // family for compatibility with the old code which used it instead of // IsFixedWidth() if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) diff --git a/src/x11/textctrl.cpp b/src/x11/textctrl.cpp index dea9579417..4c1473baa6 100644 --- a/src/x11/textctrl.cpp +++ b/src/x11/textctrl.cpp @@ -229,7 +229,7 @@ bool wxTextCtrl::Create( wxWindow *parent, m_editable = ((m_windowStyle & wxTE_READONLY) == 0); if (HasFlag(wxTE_PASSWORD)) - m_sourceFont = wxFont( 12, wxMODERN, wxNORMAL, wxNORMAL ); + m_sourceFont = wxFont( 12, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); else m_sourceFont = GetFont(); @@ -1711,7 +1711,7 @@ void wxTextCtrl::OnPaint( wxPaintEvent &event ) GetClientSize( &size_x, &size_y ); dc.SetPen( *wxTRANSPARENT_PEN ); - dc.SetBrush( wxBrush( wxTHEME_COLOUR(HIGHLIGHT), wxSOLID ) ); + dc.SetBrush( wxBrush( wxTHEME_COLOUR(HIGHLIGHT), wxBRUSHSTYLE_SOLID ) ); int upper = wxMin( (int)m_lines.GetCount(), scroll_y+(size_y/m_lineHeight)+2 ); for (int i = scroll_y; i < upper; i++) { From eb23d4735c611dd2b98c29e15a6be718866ce901 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 25 Nov 2018 20:22:44 +0100 Subject: [PATCH 115/140] Fix unannotated fall-through warnings --- demos/life/life.cpp | 2 +- demos/poem/wxpoem.cpp | 2 ++ samples/calendar/calendar.cpp | 2 +- samples/dataview/mymodels.cpp | 1 + samples/dialogs/dialogs.cpp | 1 + samples/exec/exec.cpp | 2 +- samples/image/image.cpp | 2 +- samples/power/power.cpp | 4 ++-- samples/regtest/regtest.cpp | 3 +-- samples/treelist/treelist.cpp | 2 +- samples/widgets/bmpcombobox.cpp | 2 +- samples/widgets/button.cpp | 4 ++-- samples/widgets/checkbox.cpp | 4 ++-- samples/widgets/combobox.cpp | 2 +- samples/widgets/hyperlnk.cpp | 2 +- samples/widgets/notebook.cpp | 2 +- samples/widgets/radiobox.cpp | 2 +- samples/widgets/spinbtn.cpp | 2 +- samples/widgets/static.cpp | 6 +++--- samples/widgets/textctrl.cpp | 4 +++- samples/widgets/toggle.cpp | 4 ++-- samples/widgets/widgets.cpp | 2 +- src/msw/anybutton.cpp | 6 +++--- src/msw/app.cpp | 2 +- src/msw/bitmap.cpp | 1 + src/msw/brush.cpp | 2 +- src/msw/calctrl.cpp | 2 +- src/msw/dialup.cpp | 4 ++-- src/msw/evtloopconsole.cpp | 2 +- src/msw/filedlg.cpp | 5 ++--- src/msw/font.cpp | 2 +- src/msw/listctrl.cpp | 8 ++++---- src/msw/mdi.cpp | 4 ++-- src/msw/mediactrl_am.cpp | 2 +- src/msw/msgdlg.cpp | 2 +- src/msw/ole/droptgt.cpp | 4 ++-- src/msw/pen.cpp | 6 +++--- src/msw/power.cpp | 1 + src/msw/region.cpp | 4 ++-- src/msw/registry.cpp | 4 ++-- src/msw/textctrl.cpp | 8 ++++---- src/msw/thread.cpp | 4 ++-- src/msw/treectrl.cpp | 13 ++++++------- src/msw/utils.cpp | 5 +++-- src/msw/window.cpp | 10 +++++----- src/richtext/richtextctrl.cpp | 1 + tests/regex/regextest.cpp | 2 +- 47 files changed, 84 insertions(+), 77 deletions(-) diff --git a/demos/life/life.cpp b/demos/life/life.cpp index c36e9c99d9..60f14a40ca 100644 --- a/demos/life/life.cpp +++ b/demos/life/life.cpp @@ -534,7 +534,7 @@ void LifeFrame::OnNavigate(wxCommandEvent& event) case ID_CENTER: c = m_life->FindCenter(); break; default : wxFAIL; - // Fall through! + wxFALLTHROUGH; case ID_ORIGIN: c.i = c.j = 0; break; } diff --git a/demos/poem/wxpoem.cpp b/demos/poem/wxpoem.cpp index 5b0500e0d7..9f24e2566a 100644 --- a/demos/poem/wxpoem.cpp +++ b/demos/poem/wxpoem.cpp @@ -686,6 +686,8 @@ void MyCanvas::OnChar(wxKeyEvent& event) case WXK_ESCAPE: TheMainWindow->Close(true); + break; + default: break; } diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index 14e1f616bd..54f02275d2 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -625,7 +625,7 @@ void MyFrame::OnCalRClick(wxMouseEvent& event) { default: wxFAIL_MSG( "unexpected" ); - // fall through + wxFALLTHROUGH; case wxCAL_HITTEST_NOWHERE: msg += "nowhere"; diff --git a/samples/dataview/mymodels.cpp b/samples/dataview/mymodels.cpp index ae40acb021..fcffc59d69 100644 --- a/samples/dataview/mymodels.cpp +++ b/samples/dataview/mymodels.cpp @@ -525,6 +525,7 @@ bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col, return true; } } + wxFALLTHROUGH; case Col_Custom: // do what the labels defined in GetValueByRow() hint at diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 78b92ed447..578bb940ce 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -3707,6 +3707,7 @@ long TestMessageBoxDialog::GetStyle() { case MsgDlgIcon_Max: wxFAIL_MSG( "unexpected selection" ); + wxFALLTHROUGH; case MsgDlgIcon_No: break; diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index ae5ed8f8ed..130bdcc780 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -627,7 +627,7 @@ void MyFrame::OnKill(wxCommandEvent& WXUNUSED(event)) { default: wxFAIL_MSG( "unexpected return value" ); - // fall through + wxFALLTHROUGH; case -1: // cancelled diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 949619960e..819da2578f 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -802,7 +802,7 @@ void MyFrame::OnImageInfo( wxCommandEvent &WXUNUSED(event) ) { default: wxFAIL_MSG( "unknown image resolution units" ); - // fall through + wxFALLTHROUGH; case wxIMAGE_RESOLUTION_NONE: info += " in default units"; diff --git a/samples/power/power.cpp b/samples/power/power.cpp index 6c0f6454f0..59fdfc96ba 100644 --- a/samples/power/power.cpp +++ b/samples/power/power.cpp @@ -142,7 +142,7 @@ private: default: wxFAIL_MSG("unknown wxPowerType value"); - // fall through + wxFALLTHROUGH; case wxPOWER_UNKNOWN: powerStr = "psychic"; @@ -170,7 +170,7 @@ private: default: wxFAIL_MSG("unknown wxBatteryState value"); - // fall through + wxFALLTHROUGH; case wxBATTERY_UNKNOWN_STATE: batteryStr = "unknown"; diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index b97f627625..2004e34ce9 100644 --- a/samples/regtest/regtest.cpp +++ b/samples/regtest/regtest.cpp @@ -1074,8 +1074,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() m_pKey->QueryValue(str, &l); strItem << l; } - - // fall through + wxFALLTHROUGH; default: icon = RegImageList::BinaryValue; diff --git a/samples/treelist/treelist.cpp b/samples/treelist/treelist.cpp index 0614f0ef84..b8a43a4039 100644 --- a/samples/treelist/treelist.cpp +++ b/samples/treelist/treelist.cpp @@ -695,7 +695,7 @@ void MyFrame::OnItemContextMenu(wxTreeListEvent& event) default: wxFAIL_MSG( "Unexpected menu selection" ); - // Fall through. + wxFALLTHROUGH; case wxID_NONE: return; diff --git a/samples/widgets/bmpcombobox.cpp b/samples/widgets/bmpcombobox.cpp index 56dd331fd8..bf7e7070a2 100644 --- a/samples/widgets/bmpcombobox.cpp +++ b/samples/widgets/bmpcombobox.cpp @@ -433,7 +433,7 @@ void BitmapComboBoxWidgetsPage::CreateCombo() { default: wxFAIL_MSG( "unknown combo kind" ); - // fall through + wxFALLTHROUGH; case ComboKind_Default: break; diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp index 1275372a6d..98d9473a39 100644 --- a/samples/widgets/button.cpp +++ b/samples/widgets/button.cpp @@ -416,7 +416,7 @@ void ButtonWidgetsPage::CreateButton() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ButtonHAlign_Centre: break; @@ -434,7 +434,7 @@ void ButtonWidgetsPage::CreateButton() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ButtonVAlign_Centre: // centre vertical alignment is the default (no style) diff --git a/samples/widgets/checkbox.cpp b/samples/widgets/checkbox.cpp index 09893f3029..7e5c6720fd 100644 --- a/samples/widgets/checkbox.cpp +++ b/samples/widgets/checkbox.cpp @@ -259,7 +259,7 @@ void CheckBoxWidgetsPage::CreateCheckbox() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case CheckboxKind_2State: flags |= wxCHK_2STATE; @@ -267,7 +267,7 @@ void CheckBoxWidgetsPage::CreateCheckbox() case CheckboxKind_3StateUser: flags |= wxCHK_ALLOW_3RD_STATE_FOR_USER; - // fall through + wxFALLTHROUGH; case CheckboxKind_3State: flags |= wxCHK_3STATE; diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index 57c031802b..6618ceff1a 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -431,7 +431,7 @@ void ComboboxWidgetsPage::CreateCombo() { default: wxFAIL_MSG( "unknown combo kind" ); - // fall through + wxFALLTHROUGH; case ComboKind_Default: break; diff --git a/samples/widgets/hyperlnk.cpp b/samples/widgets/hyperlnk.cpp index fb110f5a71..f71ad23a17 100644 --- a/samples/widgets/hyperlnk.cpp +++ b/samples/widgets/hyperlnk.cpp @@ -366,7 +366,7 @@ void HyperlinkWidgetsPage::OnAlignment(wxCommandEvent& WXUNUSED(event)) default: case Align_Max: wxFAIL_MSG( "unknown alignment" ); - // fall through + wxFALLTHROUGH; case Align_Left: addstyle = wxHL_ALIGN_LEFT; diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp index 08c51f1f3c..598c19f848 100644 --- a/samples/widgets/notebook.cpp +++ b/samples/widgets/notebook.cpp @@ -343,7 +343,7 @@ void BookWidgetsPage::RecreateBook() { default: wxFAIL_MSG( "unknown orientation" ); - // fall through + wxFALLTHROUGH; case Orient_Top: flags |= wxBK_TOP; diff --git a/samples/widgets/radiobox.cpp b/samples/widgets/radiobox.cpp index 2745422475..2d109a51fe 100644 --- a/samples/widgets/radiobox.cpp +++ b/samples/widgets/radiobox.cpp @@ -376,7 +376,7 @@ void RadioWidgetsPage::CreateRadio() { default: wxFAIL_MSG( "unexpected wxRadioBox layout direction" ); - // fall through + wxFALLTHROUGH; case RadioDir_Default: break; diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp index 4bda25ffef..067a3af999 100644 --- a/samples/widgets/spinbtn.cpp +++ b/samples/widgets/spinbtn.cpp @@ -368,7 +368,7 @@ void SpinBtnWidgetsPage::CreateSpin() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case Align_Left: textFlags |= wxALIGN_LEFT; // no-op diff --git a/samples/widgets/static.cpp b/samples/widgets/static.cpp index 5ae946b9f8..163d500cda 100644 --- a/samples/widgets/static.cpp +++ b/samples/widgets/static.cpp @@ -417,7 +417,7 @@ void StaticWidgetsPage::CreateStatic() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case StaticHAlign_Left: align |= wxALIGN_LEFT; @@ -436,7 +436,7 @@ void StaticWidgetsPage::CreateStatic() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case StaticVAlign_Top: align |= wxALIGN_TOP; @@ -457,7 +457,7 @@ void StaticWidgetsPage::CreateStatic() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case StaticEllipsize_Start: flagsDummyText |= wxST_ELLIPSIZE_START; diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index 8bd91ce042..8618261215 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -293,7 +293,7 @@ private: { default: wxFAIL_MSG( "unexpected HitTest() result" ); - // fall through + wxFALLTHROUGH; case wxTE_HT_UNKNOWN: x = y = -1; @@ -690,6 +690,7 @@ void TextWidgetsPage::CreateText() { default: wxFAIL_MSG( "unexpected lines radio box selection" ); + wxFALLTHROUGH; case TextLines_Single: break; @@ -755,6 +756,7 @@ void TextWidgetsPage::CreateText() { default: wxFAIL_MSG( "unexpected kind radio box selection" ); + wxFALLTHROUGH; case TextKind_Plain: break; diff --git a/samples/widgets/toggle.cpp b/samples/widgets/toggle.cpp index 83289037bc..d435642951 100644 --- a/samples/widgets/toggle.cpp +++ b/samples/widgets/toggle.cpp @@ -379,7 +379,7 @@ void ToggleWidgetsPage::CreateToggle() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ToggleHAlign_Centre: break; @@ -397,7 +397,7 @@ void ToggleWidgetsPage::CreateToggle() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ToggleVAlign_Centre: // centre vertical alignment is the default (no style) diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index 63eee2c2f8..381011490d 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -902,7 +902,7 @@ void WidgetsFrame::OnSetBorder(wxCommandEvent& event) default: wxFAIL_MSG( "unknown border style" ); - // fall through + wxFALLTHROUGH; case Widgets_BorderDefault: border = wxBORDER_DEFAULT; break; } diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index a589aed3d7..c4c4d11f53 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -280,7 +280,7 @@ public: { default: wxFAIL_MSG( "invalid image alignment" ); - // fall through + wxFALLTHROUGH; case BUTTON_IMAGELIST_ALIGN_LEFT: return wxLEFT; @@ -303,7 +303,7 @@ public: { default: wxFAIL_MSG( "invalid direction" ); - // fall through + wxFALLTHROUGH; case wxLEFT: alignNew = BUTTON_IMAGELIST_ALIGN_LEFT; @@ -1343,7 +1343,7 @@ bool wxAnyButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) { default: wxFAIL_MSG( "invalid direction" ); - // fall through + wxFALLTHROUGH; case wxLEFT: rectBitmap.x = rectButton.x + margin.x; diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 2c3d14273b..d6af9e833c 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -978,7 +978,7 @@ terminate the program,\r\n\ default: wxFAIL_MSG( wxT("unexpected MessageBox() return code") ); - // fall through + wxFALLTHROUGH; case IDRETRY: return false; diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 57bcdc4fd4..3ceea0022c 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -558,6 +558,7 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, { default: wxFAIL_MSG( wxT("unknown wxBitmapTransparency value") ); + wxFALLTHROUGH; case wxBitmapTransparency_None: // nothing to do, refData->m_hasAlpha is false by default diff --git a/src/msw/brush.cpp b/src/msw/brush.cpp index f47d6d4bd2..da94288a53 100644 --- a/src/msw/brush.cpp +++ b/src/msw/brush.cpp @@ -186,7 +186,7 @@ HBRUSH wxBrushRefData::GetHBRUSH() default: wxFAIL_MSG( wxT("unknown brush style") ); - // fall through + wxFALLTHROUGH; case wxBRUSHSTYLE_SOLID: m_hBrush = ::CreateSolidBrush(m_colour.GetPixel()); diff --git a/src/msw/calctrl.cpp b/src/msw/calctrl.cpp index a538ff60f1..f03a3f5cbd 100644 --- a/src/msw/calctrl.cpp +++ b/src/msw/calctrl.cpp @@ -196,7 +196,7 @@ wxCalendarCtrl::HitTest(const wxPoint& pos, default: case MCHT_CALENDARWEEKNUM: wxFAIL_MSG( "unexpected" ); - // fall through + wxFALLTHROUGH; case MCHT_NOWHERE: case MCHT_CALENDARBK: diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp index c38af22209..dec3014e6c 100644 --- a/src/msw/dialup.cpp +++ b/src/msw/dialup.cpp @@ -541,7 +541,7 @@ HRASCONN wxDialUpManagerMSW::FindActiveConnection() // is used, for example, to select the connection to hang up and so // we may hang up the wrong connection here... wxLogWarning(_("Several active dialup connections found, choosing one randomly.")); - // fall through + wxFALLTHROUGH; case 1: // exactly 1 connection, great @@ -1231,7 +1231,7 @@ static DWORD wxRasMonitorThread(wxRasThreadData *data) default: wxFAIL_MSG( wxT("unexpected return of WaitForMultipleObjects()") ); - // fall through + wxFALLTHROUGH; case WAIT_FAILED: // using wxLogLastError() from here is dangerous: we risk to diff --git a/src/msw/evtloopconsole.cpp b/src/msw/evtloopconsole.cpp index 869ea888fd..17706a16e4 100644 --- a/src/msw/evtloopconsole.cpp +++ b/src/msw/evtloopconsole.cpp @@ -122,7 +122,7 @@ int wxMSWEventLoopBase::GetNextMessageTimeout(WXMSG *msg, unsigned long timeout) default: wxLogDebug("unexpected MsgWaitForMultipleObjects() return " "value %lu", rc); - // fall through + wxFALLTHROUGH; case WAIT_TIMEOUT: return -1; diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 07a9932796..0c6e38681d 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -517,8 +517,7 @@ int wxFileDialog::ShowModal() case wxT('/'): // convert to backslash ch = wxT('\\'); - - // fall through + wxFALLTHROUGH; case wxT('\\'): while ( i < len - 1 ) @@ -533,7 +532,7 @@ int wxFileDialog::ShowModal() else break; } - // fall through + wxFALLTHROUGH; default: // normal char diff --git a/src/msw/font.cpp b/src/msw/font.cpp index ed9840e0e6..2a74f6d1b2 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -524,7 +524,7 @@ void wxNativeFontInfo::SetStyle(wxFontStyle style) { default: wxFAIL_MSG( "unknown font style" ); - // fall through + wxFALLTHROUGH; case wxFONTSTYLE_NORMAL: lf.lfItalic = FALSE; diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 45041dcf6f..c557c559f3 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -2145,7 +2145,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case HDN_BEGINTRACKA: case HDN_BEGINTRACKW: eventType = wxEVT_LIST_COL_BEGIN_DRAG; - // fall through + wxFALLTHROUGH; case HDN_ITEMCHANGING: if ( eventType == wxEVT_NULL ) @@ -2171,7 +2171,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) eventType = wxEVT_LIST_COL_DRAGGING; } - // fall through + wxFALLTHROUGH; case HDN_ENDTRACKA: case HDN_ENDTRACKW: @@ -2244,7 +2244,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { case LVN_BEGINRDRAG: eventType = wxEVT_LIST_BEGIN_RDRAG; - // fall through + wxFALLTHROUGH; case LVN_BEGINDRAG: if ( eventType == wxEVT_NULL ) @@ -2675,7 +2675,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) return true; } - // fall through + wxFALLTHROUGH; default: processed = false; diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 6870069d38..98e819ec92 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -722,7 +722,7 @@ void wxMDIParentFrame::OnMDICommand(wxCommandEvent& event) case wxID_MDI_WINDOW_TILE_HORZ: wParam |= MDITILE_HORIZONTAL; - // fall through + wxFALLTHROUGH; case wxID_MDI_WINDOW_TILE_VERT: if ( !wParam ) @@ -1152,7 +1152,7 @@ WXLRESULT wxMDIChildFrame::MSWWindowProc(WXUINT message, processed = HandleMDIActivate(act, hwndAct, hwndDeact); } - // fall through + wxFALLTHROUGH; case WM_MOVE: // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client diff --git a/src/msw/mediactrl_am.cpp b/src/msw/mediactrl_am.cpp index 4a15fc7fc5..5bffd76681 100644 --- a/src/msw/mediactrl_am.cpp +++ b/src/msw/mediactrl_am.cpp @@ -1369,7 +1369,7 @@ wxLongLong wxAMMediaBackend::GetDuration() { default: wxAMLOG(hr); - // fall through + wxFALLTHROUGH; case S_FALSE: return 0; diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 61a0a878a8..6ffc80b43d 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -830,7 +830,7 @@ int wxMSWMessageDialog::MSWTranslateReturnCode(int msAns) { default: wxFAIL_MSG(wxT("unexpected return code")); - // fall through + wxFALLTHROUGH; case IDCANCEL: ans = wxID_CANCEL; diff --git a/src/msw/ole/droptgt.cpp b/src/msw/ole/droptgt.cpp index e34c8d039a..acb7e44017 100644 --- a/src/msw/ole/droptgt.cpp +++ b/src/msw/ole/droptgt.cpp @@ -681,7 +681,7 @@ static wxDragResult ConvertDragEffectToResult(DWORD dwEffect) default: wxFAIL_MSG(wxT("invalid value in ConvertDragEffectToResult")); - // fall through + wxFALLTHROUGH; case DROPEFFECT_NONE: return wxDragNone; @@ -702,7 +702,7 @@ static DWORD ConvertDragResultToEffect(wxDragResult result) default: wxFAIL_MSG(wxT("invalid value in ConvertDragResultToEffect")); - // fall through + wxFALLTHROUGH; case wxDragNone: return DROPEFFECT_NONE; diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index 61a8648d3b..17360fb899 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -205,7 +205,7 @@ static int ConvertPenStyle(wxPenStyle style) default: wxFAIL_MSG( wxT("unknown pen style") ); - // fall through + wxFALLTHROUGH; case wxPENSTYLE_DOT: return PS_DOT; @@ -241,7 +241,7 @@ static int ConvertJoinStyle(wxPenJoin join) default: wxFAIL_MSG( wxT("unknown pen join style") ); - // fall through + wxFALLTHROUGH; case wxJOIN_ROUND: return PS_JOIN_ROUND; @@ -260,7 +260,7 @@ static int ConvertCapStyle(wxPenCap cap) default: wxFAIL_MSG( wxT("unknown pen cap style") ); - // fall through + wxFALLTHROUGH; case wxCAP_ROUND: return PS_ENDCAP_ROUND; diff --git a/src/msw/power.cpp b/src/msw/power.cpp index af74be0d88..92ff808675 100644 --- a/src/msw/power.cpp +++ b/src/msw/power.cpp @@ -143,6 +143,7 @@ wxPowerType wxGetPowerType() default: wxLogDebug(wxT("Unknown ACLineStatus=%u"), sps.ACLineStatus); + wxFALLTHROUGH; case 255: break; } diff --git a/src/msw/region.cpp b/src/msw/region.cpp index 8ff88073b3..b7e18d85fd 100644 --- a/src/msw/region.cpp +++ b/src/msw/region.cpp @@ -206,7 +206,7 @@ bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op) default: wxFAIL_MSG( wxT("unknown region operation") ); - // fall through + wxFALLTHROUGH; case wxRGN_AND: case wxRGN_DIFF: @@ -239,7 +239,7 @@ bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op) default: wxFAIL_MSG( wxT("unknown region operation") ); - // fall through + wxFALLTHROUGH; case wxRGN_COPY: mode = RGN_COPY; diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index 63d2e1bf70..73631b105c 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -1332,7 +1332,7 @@ wxString wxRegKey::FormatValue(const wxString& name) const case wxT('\\'): // escape special symbol rhs += wxT('\\'); - // fall through + wxFALLTHROUGH; default: rhs += *p; @@ -1527,7 +1527,7 @@ long GetMSWViewFlags(wxRegKey::WOW64ViewMode viewMode) default: wxFAIL_MSG("Unknown registry view."); - // fall through + wxFALLTHROUGH; case wxRegKey::WOW64ViewMode_Default: // Use default registry view for the current application, diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index ec96a10635..52637d901c 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1997,7 +1997,7 @@ bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* msg) { default: wxFAIL_MSG( wxT("how many modifiers have we got?") ); - // fall through + wxFALLTHROUGH; case 0: switch ( vkey ) @@ -2006,14 +2006,14 @@ bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* msg) // This one is only special for multi line controls. if ( !IsMultiLine() ) break; - // fall through + wxFALLTHROUGH; case VK_DELETE: case VK_HOME: case VK_END: return false; } - // fall through + wxFALLTHROUGH; case 2: break; @@ -2297,7 +2297,7 @@ bool wxTextCtrl::SendUpdateEvent() default: wxFAIL_MSG( wxT("unexpected wxTextCtrl::m_updatesCount value") ); - // fall through + wxFALLTHROUGH; case -1: // we hadn't updated the control ourselves, this event comes from diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 5c94613f46..a04625d4fd 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -258,7 +258,7 @@ wxMutexError wxMutexInternal::LockTimeout(DWORD milliseconds) // the previous caller died without releasing the mutex, so even // though we did get it, log a message about this wxLogDebug(wxT("WaitForSingleObject() returned WAIT_ABANDONED")); - // fall through + wxFALLTHROUGH; case WAIT_OBJECT_0: // ok @@ -269,7 +269,7 @@ wxMutexError wxMutexInternal::LockTimeout(DWORD milliseconds) default: wxFAIL_MSG(wxT("impossible return value in wxMutex::Lock")); - // fall through + wxFALLTHROUGH; case WAIT_FAILED: wxLogLastError(wxT("WaitForSingleObject(mutex)")); diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index d7e9094a02..e9f9defff4 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -3114,8 +3114,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) processed = true; } } - - // fall through + wxFALLTHROUGH; case WM_RBUTTONUP: #if wxUSE_DRAGIMAGE @@ -3288,7 +3287,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { case TVN_BEGINDRAG: eventType = wxEVT_TREE_BEGIN_DRAG; - // fall through + wxFALLTHROUGH; case TVN_BEGINRDRAG: { @@ -3379,7 +3378,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case TVN_GETDISPINFO: eventType = wxEVT_TREE_GET_INFO; - // fall through + wxFALLTHROUGH; case TVN_SETDISPINFO: { @@ -3403,7 +3402,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { default: wxLogDebug(wxT("unexpected code %d in TVN_ITEMEXPAND message"), tv->action); - // fall through + wxFALLTHROUGH; case TVE_EXPAND: what = IDX_EXPAND; @@ -3471,7 +3470,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { eventType = wxEVT_TREE_SEL_CHANGED; } - // fall through + wxFALLTHROUGH; case TVN_SELCHANGINGA: case TVN_SELCHANGINGW: @@ -3690,7 +3689,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) break; } } - // fall through + wxFALLTHROUGH; default: return wxControl::MSWOnNotify(idCtrl, lParam, result); diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 45f52c8d77..74a3a596c3 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -713,11 +713,11 @@ int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags) default: wxFAIL_MSG( wxT("unexpected WaitForSingleObject() return") ); - // fall through + wxFALLTHROUGH; case WAIT_FAILED: wxLogLastError(wxT("WaitForSingleObject")); - // fall through + wxFALLTHROUGH; case WAIT_TIMEOUT: // Process didn't terminate: normally this is a failure but not @@ -1274,6 +1274,7 @@ wxWinVersion wxGetWinVersion() case 10: return wxWinVersion_10; } + break; default: // Do nothing just to silence GCC warning break; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index d17cf3f39e..e17b851b59 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1561,7 +1561,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const default: case wxBORDER_DEFAULT: wxFAIL_MSG( wxT("unknown border style") ); - // fall through + wxFALLTHROUGH; case wxBORDER_NONE: case wxBORDER_SIMPLE: @@ -2257,7 +2257,7 @@ wxSize wxWindowMSW::DoGetBorderSize() const default: wxFAIL_MSG( wxT("unknown border style") ); - // fall through + wxFALLTHROUGH; case wxBORDER_NONE: border = 0; @@ -2540,7 +2540,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) case VK_PRIOR: bForward = false; - // fall through + wxFALLTHROUGH; case VK_NEXT: // we treat PageUp/Dn as arrows because chances are that @@ -4502,7 +4502,7 @@ bool wxWindowMSW::HandlePower(WXWPARAM wParam, default: wxLogDebug(wxT("Unknown WM_POWERBROADCAST(%d) event"), wParam); - // fall through + wxFALLTHROUGH; // these messages are currently not mapped to wx events case PBT_APMQUERYSTANDBY: @@ -5106,7 +5106,7 @@ bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc) return true; } } - // fall through + wxFALLTHROUGH; case wxBG_STYLE_SYSTEM: if ( !DoEraseBackground(hdc) ) diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index b0aab5b388..844f264419 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -878,6 +878,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) Refresh(); // This is needed in wxMSW, otherwise resetting the position doesn't 'take' SetCaretPosition(oldPos); SetFocusObject(oldFocus, false); + wxFALLTHROUGH; default: break; } EndBatchUndo(); diff --git a/tests/regex/regextest.cpp b/tests/regex/regextest.cpp index 2c26019dc5..cc9449e9b7 100644 --- a/tests/regex/regextest.cpp +++ b/tests/regex/regextest.cpp @@ -204,7 +204,7 @@ void RegExTestCase::parseFlags(const wxString& flags) case 'i': m_compileFlags |= wxRE_ICASE; break; case 'o': m_compileFlags |= wxRE_NOSUB; break; case 'n': m_compileFlags |= wxRE_NEWLINE; break; - case 't': if (strchr("ep", m_mode)) break; // else fall through... + case 't': if (strchr("ep", m_mode)) break; wxFALLTHROUGH; // anything else we must skip the test default: From bcf53d6b96f3714181d63e2d45ad642838d44074 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 25 Nov 2018 20:22:55 +0100 Subject: [PATCH 116/140] Fix extra semicolon warnings --- demos/bombs/game.h | 24 ++++++++++++------------ demos/forty/card.h | 8 ++++---- demos/forty/forty.h | 2 +- demos/forty/pile.h | 4 ++-- demos/forty/playerdg.h | 2 +- demos/forty/scoredg.h | 2 +- demos/life/game.cpp | 2 +- demos/life/game.h | 10 +++++----- demos/life/life.h | 10 +++++----- demos/life/reader.h | 10 +++++----- include/wx/generic/dataview.h | 2 +- samples/dragimag/dragimag.h | 2 +- samples/ipc/baseclient.cpp | 2 +- samples/ipc/baseserver.cpp | 2 +- samples/ipc/client.h | 6 +++--- samples/joytest/joytest.h | 2 +- samples/layout/layout.h | 2 +- samples/nativdlg/nativdlg.h | 2 +- samples/opengl/pyramid/pyramid.h | 2 +- samples/ownerdrw/ownerdrw.cpp | 2 +- samples/splitter/splitter.cpp | 2 +- samples/stc/edit.h | 6 +++--- samples/thread/thread.cpp | 2 +- samples/treectrl/treetest.h | 2 +- samples/xrc/custclas.h | 2 +- samples/xrc/derivdlg.h | 2 +- src/msw/joystick.cpp | 2 +- 27 files changed, 58 insertions(+), 58 deletions(-) diff --git a/demos/bombs/game.h b/demos/bombs/game.h index 0f062c6027..0463ddfd25 100644 --- a/demos/bombs/game.h +++ b/demos/bombs/game.h @@ -27,17 +27,17 @@ public: { m_width = m_height = 0; m_field = NULL; - }; + } ~BombsGame(); - int GetWidth() const { return m_width; }; - int GetHeight() const { return m_height; }; + int GetWidth() const { return m_width; } + int GetHeight() const { return m_height; } int Get(int x, int y) const { return m_field[x+y*m_width]; - }; + } int IsFocussed(int x, int y) const { @@ -47,42 +47,42 @@ public: int IsHidden(int x, int y) const { return Get(x,y) & BG_HIDDEN; - }; + } int IsMarked(int x, int y) const { return Get(x,y) & BG_MARKED; - }; + } int IsBomb(int x, int y) const { return Get(x,y) & BG_BOMB; - }; + } int IsExploded(int x, int y) const { return Get(x,y) & BG_EXPLODED; - }; + } int IsSelected(int x, int y) const { return Get(x,y) & BG_SELECTED; - }; + } int GetNumBombs() const { return m_numBombCells; - }; + } int GetNumRemainingCells() const { return m_numRemainingCells; - }; + } int GetNumMarkedCells() const { return m_numMarkedCells; - }; + } bool Init(int width, int height, bool easyCorner = false); diff --git a/demos/forty/card.h b/demos/forty/card.h index bb64d279dc..65c8f854ba 100644 --- a/demos/forty/card.h +++ b/demos/forty/card.h @@ -43,7 +43,7 @@ class Card { public: Card(int value, WayUp way_up = facedown); - virtual ~Card(){}; + virtual ~Card(){} void Draw(wxDC& pDC, int x, int y); static void DrawNullCard(wxDC& pDC, int x, int y); // Draw card place-holder @@ -55,9 +55,9 @@ public: Suit GetSuit() const { return m_suit; } SuitColour GetColour() const { return m_colour; } static void SetScale(double scale); - static int GetHeight() { return m_height; }; - static int GetWidth() { return m_width; }; - static double GetScale() { return m_scale; }; + static int GetHeight() { return m_height; } + static int GetWidth() { return m_width; } + static double GetScale() { return m_scale; } private: Suit m_suit; diff --git a/demos/forty/forty.h b/demos/forty/forty.h index 815514d0a5..6753b19417 100644 --- a/demos/forty/forty.h +++ b/demos/forty/forty.h @@ -38,7 +38,7 @@ class FortyFrame: public wxFrame { public: FortyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size, bool largecards); - virtual ~FortyFrame(){}; + virtual ~FortyFrame(){} void OnCloseWindow(wxCloseEvent& event); diff --git a/demos/forty/pile.h b/demos/forty/pile.h index 21f35ba08b..3aeb517bc7 100644 --- a/demos/forty/pile.h +++ b/demos/forty/pile.h @@ -41,7 +41,7 @@ const int NumCards = 2 * PackSize; class Pile { public: Pile(int x, int y, int dx = 0, int dy = 0); - virtual ~Pile(){}; + virtual ~Pile(){} // General functions virtual void ResetPile() { m_topCard = -1; } @@ -68,7 +68,7 @@ public: virtual bool AcceptCard(Card*) { return false; } virtual void AddCard(Card* card); // Add card to top of pile virtual void AddCard(wxDC& pDC, Card* card); // Add card + redraw it - void SetPos(int x,int y) {m_x = x;m_y = y;}; + void SetPos(int x,int y) {m_x = x;m_y = y;} protected: int m_x, m_y; // Position of the pile on the screen diff --git a/demos/forty/playerdg.h b/demos/forty/playerdg.h index 59836ae141..1be65322e5 100644 --- a/demos/forty/playerdg.h +++ b/demos/forty/playerdg.h @@ -16,7 +16,7 @@ class PlayerSelectionDialog : public wxDialog { public: PlayerSelectionDialog(wxWindow* parent, ScoreFile* file); - virtual ~PlayerSelectionDialog(){}; + virtual ~PlayerSelectionDialog(){} const wxString& GetPlayersName(); void ButtonCallback(wxCommandEvent& event); diff --git a/demos/forty/scoredg.h b/demos/forty/scoredg.h index 1b1c7d2ba3..06a3b69ef4 100644 --- a/demos/forty/scoredg.h +++ b/demos/forty/scoredg.h @@ -16,7 +16,7 @@ class ScoreDialog : public wxDialog { public: ScoreDialog(wxWindow* parent, ScoreFile* file); - virtual ~ScoreDialog(){}; + virtual ~ScoreDialog(){} void Display(); diff --git a/demos/life/game.cpp b/demos/life/game.cpp index 62440bd53b..b509a259f5 100644 --- a/demos/life/game.cpp +++ b/demos/life/game.cpp @@ -925,7 +925,7 @@ class LifeModule: public wxModule wxDECLARE_DYNAMIC_CLASS(LifeModule); public: - LifeModule() {}; + LifeModule() {} bool OnInit() wxOVERRIDE; void OnExit() wxOVERRIDE; }; diff --git a/demos/life/game.h b/demos/life/game.h index 6fbf1fedd6..35e28a74e0 100644 --- a/demos/life/game.h +++ b/demos/life/game.h @@ -29,7 +29,7 @@ public: m_description = description; m_rules = rules; m_shape = shape; - }; + } // A more convenient ctor for the built-in samples LifePattern(wxString name, @@ -58,7 +58,7 @@ public: m_shape.Add( tmp ); } - }; + } wxString m_name; wxString m_description; @@ -90,9 +90,9 @@ public: ~Life(); // accessors - inline wxUint32 GetNumCells() const { return m_numcells; }; - inline wxString GetRules() const { return m_rules; }; - inline wxString GetDescription() const { return m_description; }; + inline wxUint32 GetNumCells() const { return m_numcells; } + inline wxString GetRules() const { return m_rules; } + inline wxString GetDescription() const { return m_description; } bool IsAlive(wxInt32 x, wxInt32 y); void SetCell(wxInt32 x, wxInt32 y, bool alive = true); void SetPattern(const LifePattern &pattern); diff --git a/demos/life/life.h b/demos/life/life.h index 1d4d2f1f0a..b2144f5170 100644 --- a/demos/life/life.h +++ b/demos/life/life.h @@ -31,7 +31,7 @@ public: virtual ~LifeCanvas(); // view management - int GetCellSize() const { return m_cellsize; }; + int GetCellSize() const { return m_cellsize; } void SetCellSize(int cellsize); void Recenter(wxInt32 i, wxInt32 j); @@ -54,10 +54,10 @@ private: void OnEraseBackground(wxEraseEvent& event); // conversion between cell and screen coordinates - inline wxInt32 XToCell(wxCoord x) const { return (x / m_cellsize) + m_viewportX; }; - inline wxInt32 YToCell(wxCoord y) const { return (y / m_cellsize) + m_viewportY; }; - inline wxCoord CellToX(wxInt32 i) const { return (i - m_viewportX) * m_cellsize; }; - inline wxCoord CellToY(wxInt32 j) const { return (j - m_viewportY) * m_cellsize; }; + inline wxInt32 XToCell(wxCoord x) const { return (x / m_cellsize) + m_viewportX; } + inline wxInt32 YToCell(wxCoord y) const { return (y / m_cellsize) + m_viewportY; } + inline wxCoord CellToX(wxInt32 i) const { return (i - m_viewportX) * m_cellsize; } + inline wxCoord CellToY(wxInt32 j) const { return (j - m_viewportY) * m_cellsize; } // what is the user doing? enum MouseStatus diff --git a/demos/life/reader.h b/demos/life/reader.h index 4480af5ed1..4ae6e33a76 100644 --- a/demos/life/reader.h +++ b/demos/life/reader.h @@ -22,14 +22,14 @@ class LifeReader public: LifeReader(wxInputStream& is); - inline bool IsOk() const { return m_ok; }; - inline wxString GetDescription() const { return m_description; }; - inline wxString GetRules() const { return m_rules; }; - inline wxArrayString GetShape() const { return m_shape; }; + inline bool IsOk() const { return m_ok; } + inline wxString GetDescription() const { return m_description; } + inline wxString GetRules() const { return m_rules; } + inline wxArrayString GetShape() const { return m_shape; } inline LifePattern GetPattern() const { return LifePattern(wxEmptyString, m_description, m_rules, m_shape); - }; + } private: bool m_ok; diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index aff77abd29..815dfcb75b 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -409,7 +409,7 @@ class WXDLLIMPEXP_CORE wxDataViewCtrlAccessible: public wxWindowAccessible { public: wxDataViewCtrlAccessible(wxDataViewCtrl* win); - virtual ~wxDataViewCtrlAccessible() {}; + virtual ~wxDataViewCtrlAccessible() {} virtual wxAccStatus HitTest(const wxPoint& pt, int* childId, wxAccessible** childObject) wxOVERRIDE; diff --git a/samples/dragimag/dragimag.h b/samples/dragimag/dragimag.h index c30bd3edba..ca4034a996 100644 --- a/samples/dragimag/dragimag.h +++ b/samples/dragimag/dragimag.h @@ -122,7 +122,7 @@ class DragShape: public wxObject { public: DragShape(const wxBitmap& bitmap); - ~DragShape(){}; + ~DragShape(){} //// Operations diff --git a/samples/ipc/baseclient.cpp b/samples/ipc/baseclient.cpp index a3f139987e..c958ed91cb 100644 --- a/samples/ipc/baseclient.cpp +++ b/samples/ipc/baseclient.cpp @@ -78,7 +78,7 @@ public: bool Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic); void Disconnect(); wxConnectionBase *OnMakeConnection() wxOVERRIDE; - bool IsConnected() { return m_connection != NULL; }; + bool IsConnected() { return m_connection != NULL; } virtual void Notify() wxOVERRIDE; diff --git a/samples/ipc/baseserver.cpp b/samples/ipc/baseserver.cpp index 47a29085ce..8c58305f9f 100644 --- a/samples/ipc/baseserver.cpp +++ b/samples/ipc/baseserver.cpp @@ -113,7 +113,7 @@ public: MyServer(); virtual ~MyServer(); void Disconnect(); - bool IsConnected() { return m_connection != NULL; }; + bool IsConnected() { return m_connection != NULL; } virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) wxOVERRIDE; diff --git a/samples/ipc/client.h b/samples/ipc/client.h index 8e44ffe546..7c1d58b207 100644 --- a/samples/ipc/client.h +++ b/samples/ipc/client.h @@ -31,7 +31,7 @@ class MyApp: public wxApp public: virtual bool OnInit() wxOVERRIDE; virtual int OnExit() wxOVERRIDE; - MyFrame *GetFrame() { return m_frame; }; + MyFrame *GetFrame() { return m_frame; } protected: MyFrame *m_frame; @@ -96,8 +96,8 @@ public: bool Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic); void Disconnect(); wxConnectionBase *OnMakeConnection() wxOVERRIDE; - bool IsConnected() { return m_connection != NULL; }; - MyConnection *GetConnection() { return m_connection; }; + bool IsConnected() { return m_connection != NULL; } + MyConnection *GetConnection() { return m_connection; } protected: MyConnection *m_connection; diff --git a/samples/joytest/joytest.h b/samples/joytest/joytest.h index 59d4afb5e2..76876e2e4d 100644 --- a/samples/joytest/joytest.h +++ b/samples/joytest/joytest.h @@ -44,7 +44,7 @@ public: MyCanvas *canvas; MyFrame(wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); - ~MyFrame(){}; + ~MyFrame(){} void OnActivate(wxActivateEvent& event); void OnQuit(wxCommandEvent& event); diff --git a/samples/layout/layout.h b/samples/layout/layout.h index 40627037d1..fdfd4a0c5f 100644 --- a/samples/layout/layout.h +++ b/samples/layout/layout.h @@ -12,7 +12,7 @@ class MyApp: public wxApp { public: - MyApp(){}; + MyApp(){} bool OnInit() wxOVERRIDE; }; diff --git a/samples/nativdlg/nativdlg.h b/samples/nativdlg/nativdlg.h index 468b0ed2c9..732f881704 100644 --- a/samples/nativdlg/nativdlg.h +++ b/samples/nativdlg/nativdlg.h @@ -12,7 +12,7 @@ class MyApp: public wxApp { public: - MyApp(void){}; + MyApp(void){} bool OnInit(void) wxOVERRIDE; }; diff --git a/samples/opengl/pyramid/pyramid.h b/samples/opengl/pyramid/pyramid.h index aacce137a9..fdffd31455 100644 --- a/samples/opengl/pyramid/pyramid.h +++ b/samples/opengl/pyramid/pyramid.h @@ -14,7 +14,7 @@ class MyApp: public wxApp { public: - MyApp(){}; + MyApp(){} bool OnInit() wxOVERRIDE; }; diff --git a/samples/ownerdrw/ownerdrw.cpp b/samples/ownerdrw/ownerdrw.cpp index d82a3f0032..c1ae01437c 100644 --- a/samples/ownerdrw/ownerdrw.cpp +++ b/samples/ownerdrw/ownerdrw.cpp @@ -40,7 +40,7 @@ class OwnerDrawnFrame : public wxFrame public: // ctor & dtor OwnerDrawnFrame(wxFrame *frame, const wxString& title, int x, int y, int w, int h); - ~OwnerDrawnFrame(){}; + ~OwnerDrawnFrame(){} // notifications void OnQuit (wxCommandEvent& event); diff --git a/samples/splitter/splitter.cpp b/samples/splitter/splitter.cpp index 08fd17f7c0..a91357af61 100644 --- a/samples/splitter/splitter.cpp +++ b/samples/splitter/splitter.cpp @@ -151,7 +151,7 @@ class MyCanvas: public wxScrolledWindow { public: MyCanvas(wxWindow* parent, bool mirror); - virtual ~MyCanvas(){}; + virtual ~MyCanvas(){} virtual void OnDraw(wxDC& dc) wxOVERRIDE; diff --git a/samples/stc/edit.h b/samples/stc/edit.h index 908990e757..703ebae395 100644 --- a/samples/stc/edit.h +++ b/samples/stc/edit.h @@ -112,7 +112,7 @@ public: wxString DeterminePrefs (const wxString &filename); bool InitializePrefs (const wxString &filename); bool UserSettings (const wxString &filename); - LanguageInfo const* GetLanguageInfo () {return m_language;}; + LanguageInfo const* GetLanguageInfo () {return m_language;} //! load/save file bool LoadFile (); @@ -120,8 +120,8 @@ public: bool SaveFile (); bool SaveFile (const wxString &filename); bool Modified (); - wxString GetFilename () {return m_filename;}; - void SetFilename (const wxString &filename) {m_filename = filename;}; + wxString GetFilename () {return m_filename;} + void SetFilename (const wxString &filename) {m_filename = filename;} private: // file diff --git a/samples/thread/thread.cpp b/samples/thread/thread.cpp index 60c0f18005..7b3a706938 100644 --- a/samples/thread/thread.cpp +++ b/samples/thread/thread.cpp @@ -66,7 +66,7 @@ class MyApp : public wxApp { public: MyApp(); - virtual ~MyApp(){}; + virtual ~MyApp(){} virtual bool OnInit() wxOVERRIDE; diff --git a/samples/treectrl/treetest.h b/samples/treectrl/treetest.h index c615a483bc..99182002d0 100644 --- a/samples/treectrl/treetest.h +++ b/samples/treectrl/treetest.h @@ -67,7 +67,7 @@ public: MyTreeCtrl(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style); - virtual ~MyTreeCtrl(){}; + virtual ~MyTreeCtrl(){} void OnBeginDrag(wxTreeEvent& event); void OnBeginRDrag(wxTreeEvent& event); diff --git a/samples/xrc/custclas.h b/samples/xrc/custclas.h index 0a72b87394..85f1913d21 100644 --- a/samples/xrc/custclas.h +++ b/samples/xrc/custclas.h @@ -60,7 +60,7 @@ public: ); // Destructor. - ~MyResizableListCtrl(){}; + ~MyResizableListCtrl(){} protected: diff --git a/samples/xrc/derivdlg.h b/samples/xrc/derivdlg.h index 0707a1740b..4c7ef36b6b 100644 --- a/samples/xrc/derivdlg.h +++ b/samples/xrc/derivdlg.h @@ -36,7 +36,7 @@ public: PreferencesDialog( wxWindow* parent ); // Destructor. - ~PreferencesDialog(){}; + ~PreferencesDialog(){} private: diff --git a/src/msw/joystick.cpp b/src/msw/joystick.cpp index b53aeb6d23..761477f833 100644 --- a/src/msw/joystick.cpp +++ b/src/msw/joystick.cpp @@ -67,7 +67,7 @@ public: { m_catchwin = win; m_polling = pollingFreq; - }; + } private: From 3bab07edcfd3b8f746d4b1ee9f41da73f9ca071c Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 25 Nov 2018 20:23:05 +0100 Subject: [PATCH 117/140] Fix some build warnings private field 'm_dwCookie' is not used 'return' will never be executed result of comparison of unsigned enum expression < 0 is always false 'FlushDC' overrides a member function but is not marked 'override' potentially uninitialized local variable 'bound' used --- include/wx/msw/webview_ie.h | 1 - samples/dll/sdk_exe.cpp | 2 -- src/msw/dc.cpp | 2 +- tests/graphics/affinematrix.cpp | 2 +- tests/graphics/clippingbox.cpp | 4 ++-- tests/misc/safearrayconverttest.cpp | 4 ++-- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index f1e7773f89..3a4f042c16 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -157,7 +157,6 @@ private: wxIEContainer* m_container; wxAutomationObject m_ie; IWebBrowser2* m_webBrowser; - DWORD m_dwCookie; wxCOMPtr m_uiHandler; //We store the current zoom type; diff --git a/samples/dll/sdk_exe.cpp b/samples/dll/sdk_exe.cpp index b090eb6afc..7e5c127029 100644 --- a/samples/dll/sdk_exe.cpp +++ b/samples/dll/sdk_exe.cpp @@ -82,8 +82,6 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) default: return DefWindowProc(hwnd, msg, wParam, lParam); } - - return 0; } // ---------------------------------------------------------------------------- diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 0c874ae457..51cf1fe9a5 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1713,7 +1713,7 @@ void wxMSWDCImpl::SetLogicalFunction(wxRasterOperationMode function) void wxMSWDCImpl::SetRop(WXHDC dc) { - if ( !dc || m_logicalFunction < 0 ) + if ( !dc ) return; int rop; diff --git a/tests/graphics/affinematrix.cpp b/tests/graphics/affinematrix.cpp index 130c95424b..f2fbdbef67 100644 --- a/tests/graphics/affinematrix.cpp +++ b/tests/graphics/affinematrix.cpp @@ -311,7 +311,7 @@ public: m_gcdc->SetGraphicsContext(ctx); } - virtual void FlushDC() + virtual void FlushDC() wxOVERRIDE { // Apparently, flushing native Direct2D renderer // is not enough to update underlying DC (bitmap) diff --git a/tests/graphics/clippingbox.cpp b/tests/graphics/clippingbox.cpp index 87f56119e9..65ab7ab379 100644 --- a/tests/graphics/clippingbox.cpp +++ b/tests/graphics/clippingbox.cpp @@ -414,7 +414,7 @@ public: virtual ~ClippingBoxTestCaseGCDCDirect2D() {} - virtual void FlushDC() + virtual void FlushDC() wxOVERRIDE { // Apparently, flushing native Direct2D renderer // is not enough to update underlying DC (bitmap) @@ -1616,7 +1616,7 @@ public: virtual ~ClippingBoxTestCaseGCDirect2D() {} - virtual void FlushGC() + virtual void FlushGC() wxOVERRIDE { // Apparently, flushing native Direct2D renderer // is not enough to update underlying DC (bitmap) diff --git a/tests/misc/safearrayconverttest.cpp b/tests/misc/safearrayconverttest.cpp index 495245a805..96d49b1ab9 100644 --- a/tests/misc/safearrayconverttest.cpp +++ b/tests/misc/safearrayconverttest.cpp @@ -126,7 +126,7 @@ void SafeArrayConvertTestCase::VariantListReturnSafeArray() wxVariantDataSafeArray* vsa = wxStaticCastVariantData(variantCopy.GetData(), wxVariantDataSafeArray); - long bound; + long bound wxDUMMY_INITIALIZE(0); CPPUNIT_ASSERT( vsa ); CPPUNIT_ASSERT( safeArray.Attach(vsa->GetValue()) ); @@ -177,7 +177,7 @@ void SafeArrayConvertTestCase::StringsReturnSafeArray() wxVariantDataSafeArray* vsa = wxStaticCastVariantData(variant.GetData(), wxVariantDataSafeArray); - long bound; + long bound wxDUMMY_INITIALIZE(0); CPPUNIT_ASSERT( vsa ); CPPUNIT_ASSERT( safeArray.Attach(vsa->GetValue()) ); From 2f78849d24ab7601940130e711899cb767bcd797 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Mon, 26 Nov 2018 23:48:08 +0100 Subject: [PATCH 118/140] Fix build without precompiled headers --- include/wx/html/htmlcell.h | 1 + src/html/m_fonts.cpp | 1 + tests/filename/filenametest.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index c02a128143..5276a7b601 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -17,6 +17,7 @@ #include "wx/html/htmltag.h" #include "wx/html/htmldefs.h" #include "wx/window.h" +#include "wx/brush.h" class WXDLLIMPEXP_FWD_HTML wxHtmlWindowInterface; diff --git a/src/html/m_fonts.cpp b/src/html/m_fonts.cpp index 35e229de02..109db31967 100644 --- a/src/html/m_fonts.cpp +++ b/src/html/m_fonts.cpp @@ -15,6 +15,7 @@ #if wxUSE_HTML && wxUSE_STREAMS #ifndef WX_PRECOMP + #include "wx/brush.h" #endif #include "wx/html/forcelnk.h" diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index bba94b23cd..240e95205c 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -27,7 +27,7 @@ #ifdef __WINDOWS__ #include "wx/msw/registry.h" - #include + #include "wx/msw/wrapshl.h" #include "wx/msw/ole/oleutils.h" #include "wx/msw/private/comptr.h" #endif // __WINDOWS__ From 1c5cbe0a617ebc7b76f8605f997ef02a61d5fa8a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 1 Dec 2018 13:38:43 +0100 Subject: [PATCH 119/140] CMake: Add support for webkit2 --- build/cmake/files.cmake | 4 +++ build/cmake/init.cmake | 15 +++++++++-- build/cmake/lib/webview/CMakeLists.txt | 32 +++++++++++++++------- build/cmake/modules/FindWebkit.cmake | 22 ++++++++------- build/cmake/modules/FindWebkit2.cmake | 37 ++++++++++++++++++++++++++ build/cmake/options.cmake | 2 +- build/files | 3 +++ 7 files changed, 93 insertions(+), 22 deletions(-) create mode 100644 build/cmake/modules/FindWebkit2.cmake diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 455e2d2f11..0f0adadf14 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -2869,6 +2869,10 @@ set(WEBVIEW_GTK_SRC src/gtk/webview_webkit.cpp ) +set(WEBVIEW2_GTK_SRC + src/gtk/webview_webkit2.cpp +) + set(XRC_SRC src/xrc/xh_activityindicator.cpp src/xrc/xh_animatctrl.cpp diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 292440380f..0c9e420f75 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -225,8 +225,19 @@ if(wxUSE_GUI) if(wxUSE_WEBVIEW AND WXGTK) find_package(LibSoup) - find_package(Webkit) - if(NOT WEBKIT_FOUND OR NOT LIBSOUP_FOUND) + if(WXGTK2) + find_package(Webkit 1.0) + elseif(WXGTK3) + find_package(Webkit 3.0) + find_package(Webkit2) + if(NOT WEBKIT2_FOUND) + wx_option_force_value(wxUSE_WEBVIEW_WEBKIT2 OFF) + endif() + endif() + if(NOT WEBKIT_FOUND) + wx_option_force_value(wxUSE_WEBVIEW_WEBKIT OFF) + endif() + if((NOT WEBKIT_FOUND AND NOT WEBKIT2_FOUND) OR NOT LIBSOUP_FOUND) message(WARNING "webkit not found, wxWebview won't be available") wx_option_force_value(wxUSE_WEBVIEW OFF) endif() diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 317bb1be62..c7055be359 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -14,25 +14,39 @@ wx_append_sources(WEBVIEW_FILES WEBVIEW_CMN) if(WXMSW) wx_append_sources(WEBVIEW_FILES WEBVIEW_MSW) elseif(WXGTK) - wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK) + if(wxUSE_WEBVIEW_WEBKIT2) + wx_append_sources(WEBVIEW_FILES WEBVIEW2_GTK) + elseif(wxUSE_WEBVIEW_WEBKIT) + wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK) + endif() elseif(APPLE) wx_append_sources(WEBVIEW_FILES WEBVIEW_OSX_SHARED) endif() wx_add_library(webview ${WEBVIEW_FILES}) + +if(wxUSE_WEBVIEW_WEBKIT2) + wx_lib_compile_definitions(webview PRIVATE + -DWX_WEB_EXTENSIONS_DIRECTORY="${CMAKE_INSTALL_PREFIX}/web-extensions" + ) +endif() + if(APPLE) wx_lib_link_libraries(webview PUBLIC "-framework WebKit" ) elseif(WXGTK) - wx_lib_include_directories(webview PUBLIC - ${WEBKIT_INCLUDE_DIR} - ${LIBSOUP_INCLUDE_DIRS} - ) - wx_lib_link_libraries(webview PUBLIC - ${WEBKIT_LIBRARIES} - ${LIBSOUP_LIBRARIES} - ) + if(LIBSOUP_FOUND) + wx_lib_include_directories(webview PUBLIC ${LIBSOUP_INCLUDE_DIRS}) + wx_lib_link_libraries(webview PUBLIC ${LIBSOUP_LIBRARIES}) + endif() + if(wxUSE_WEBVIEW_WEBKIT2) + wx_lib_include_directories(webview PUBLIC ${WEBKIT2_INCLUDE_DIR}) + wx_lib_link_libraries(webview PUBLIC ${WEBKIT2_LIBRARIES}) + elseif(wxUSE_WEBVIEW_WEBKIT) + wx_lib_include_directories(webview PUBLIC ${WEBKIT_INCLUDE_DIR}) + wx_lib_link_libraries(webview PUBLIC ${WEBKIT_LIBRARIES}) + endif() endif() wx_finalize_lib(webview) diff --git a/build/cmake/modules/FindWebkit.cmake b/build/cmake/modules/FindWebkit.cmake index 1bb331cf69..8b6e6ccef7 100644 --- a/build/cmake/modules/FindWebkit.cmake +++ b/build/cmake/modules/FindWebkit.cmake @@ -1,16 +1,18 @@ -# - Find Webkit-3.0 -# Find the Webkit-3.0 includes and library +# - Find Webkit +# Find the Webkit includes and library # # WEBKIT_INCLUDE_DIR - Where to find webkit include sub-directory. -# WEBKIT_LIBRARIES - List of libraries when using Webkit-3.0. -# WEBKIT_FOUND - True if Webkit-3.0 found. +# WEBKIT_LIBRARIES - List of libraries when using Webkit. +# WEBKIT_FOUND - True if Webkit found. -SET( WEBKIT_VERSION "1.0") +SET(WEBKIT_VERSION 1.0) +if(DEFINED Webkit_FIND_VERSION) + SET(WEBKIT_VERSION ${Webkit_FIND_VERSION}) +endif() -IF (WEBKIT_INCLUDE_DIR) - # Already in cache, be silent. - SET(WEBKIT_FIND_QUIETLY TRUE) -ENDIF (WEBKIT_INCLUDE_DIR) +SET(WEBKIT_INCLUDE_DIR WEBKIT_INCLUDE_DIR-NOTFOUND) +SET(WEBKIT_LIBRARY WEBKIT_LIBRARY-NOTFOUND) +SET(WEBKIT_LIBRARIES WEBKIT_LIBRARIES-NOTFOUND) FIND_PATH(WEBKIT_INCLUDE_DIR webkit/webkit.h PATH_SUFFIXES "webkitgtk-${WEBKIT_VERSION}" @@ -35,4 +37,4 @@ ELSE(WEBKIT_FOUND) SET( WEBKIT_LIBRARIES ) ENDIF(WEBKIT_FOUND) -MARK_AS_ADVANCED( WEBKIT_LIBRARY WEBKIT_INCLUDE_DIR ) +MARK_AS_ADVANCED(WEBKIT_LIBRARY WEBKIT_LIBRARIES WEBKIT_INCLUDE_DIR) diff --git a/build/cmake/modules/FindWebkit2.cmake b/build/cmake/modules/FindWebkit2.cmake new file mode 100644 index 0000000000..33a8e4a863 --- /dev/null +++ b/build/cmake/modules/FindWebkit2.cmake @@ -0,0 +1,37 @@ +# - Find Webkit2 +# Find the Webkit2 includes and library +# +# WEBKIT2_INCLUDE_DIR - Where to find Webkit2 include sub-directory. +# WEBKIT2_LIBRARIES - List of libraries when using Webkit2. +# WEBKIT2_FOUND - True if Webkit2 found. + +SET( WEBKIT2_VERSION 4.0) + +set(WEBKIT2_INCLUDE_DIR WEBKIT2_INCLUDE_DIR-NOTFOUND) +set(WEBKIT2_LIBRARY WEBKIT2_LIBRARY-NOTFOUND) +set(WEBKIT2_LIBRARIES WEBKIT2_LIBRARIES-NOTFOUND) + +FIND_PATH(WEBKIT2_INCLUDE_DIR webkit2/webkit2.h + PATH_SUFFIXES "webkitgtk-${WEBKIT2_VERSION}" +) + +SET(WEBKIT2_NAMES "webkit2gtk-${WEBKIT2_VERSION}") +FIND_LIBRARY(WEBKIT2_LIBRARY + NAMES ${WEBKIT2_NAMES} +) + +# Handle the QUIETLY and REQUIRED arguments and set WEBKIT2_FOUND to +# TRUE if all listed variables are TRUE. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + WEBKIT2 DEFAULT_MSG + WEBKIT2_LIBRARY WEBKIT2_INCLUDE_DIR +) + +IF(WEBKIT2_FOUND) + SET( WEBKIT2_LIBRARIES ${WEBKIT2_LIBRARY} ) +ELSE(WEBKIT2_FOUND) + SET( WEBKIT2_LIBRARIES ) +ENDIF(WEBKIT2_FOUND) + +MARK_AS_ADVANCED(WEBKIT2_LIBRARY WEBKIT2_LIBRARIES WEBKIT2_INCLUDE_DIR) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 0cf3740002..a972de41da 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -356,7 +356,7 @@ wx_option(wxUSE_DRAGIMAGE "use wxDragImage") wx_option(wxUSE_UIACTIONSIMULATOR "use wxUIActionSimulator (experimental)") wx_option(wxUSE_DC_TRANSFORM_MATRIX "use wxDC::SetTransformMatrix and related") wx_option(wxUSE_WEBVIEW_WEBKIT "use wxWebView WebKit backend") -# TODO: wxUSE_WEBVIEW_WEBKIT2 +wx_option(wxUSE_WEBVIEW_WEBKIT2 "use wxWebView WebKit2 backend") if(WIN32 OR APPLE) set(wxUSE_PRIVATE_FONTS_DEFAULT ON) else() diff --git a/build/files b/build/files index 93c9fec7dd..fa83ae8e71 100644 --- a/build/files +++ b/build/files @@ -2812,6 +2812,9 @@ WEBVIEW_GTK_HDR = WEBVIEW_GTK_SRC = src/gtk/webview_webkit.cpp +WEBVIEW2_GTK_SRC = + src/gtk/webview_webkit2.cpp + # wxXRC XRC_SRC = From 97f64e994172de6a30f9e880b5f2ef9da831526a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 1 Dec 2018 13:41:06 +0100 Subject: [PATCH 120/140] CMake: Build the webextensions plugin --- build/cmake/files.cmake | 4 +++ build/cmake/lib/webview/CMakeLists.txt | 35 +++++++++++++++++++++++++- build/files | 3 +++ src/gtk/webview_webkit2.cpp | 3 ++- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 0f0adadf14..2724cc1b68 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -2873,6 +2873,10 @@ set(WEBVIEW2_GTK_SRC src/gtk/webview_webkit2.cpp ) +set(WEBVIEW_WEBKIT2_EXTENSION_SRC + src/gtk/webview_webkit2_extension.cpp +) + set(XRC_SRC src/xrc/xh_activityindicator.cpp src/xrc/xh_animatctrl.cpp diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index c7055be359..8ec75c726d 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -26,8 +26,9 @@ endif() wx_add_library(webview ${WEBVIEW_FILES}) if(wxUSE_WEBVIEW_WEBKIT2) + set(WX_WEB_EXTENSIONS_DIRECTORY "lib/wx/${wxMAJOR_VERSION}.${wxMINOR_VERSION}/web-extensions") wx_lib_compile_definitions(webview PRIVATE - -DWX_WEB_EXTENSIONS_DIRECTORY="${CMAKE_INSTALL_PREFIX}/web-extensions" + -DWX_WEB_EXTENSIONS_DIRECTORY="${CMAKE_INSTALL_PREFIX}/${WX_WEB_EXTENSIONS_DIRECTORY}" ) endif() @@ -50,3 +51,35 @@ elseif(WXGTK) endif() wx_finalize_lib(webview) + +# webkit extension plugin +# we can't use (all of the) macros and functions because this library should +# always be build as a shared libary, and not included in the monolithic build. +if(WXGTK AND LIBSOUP_FOUND AND wxUSE_WEBVIEW_WEBKIT2) + wx_append_sources(WEBKIT2_EXT_FILES WEBVIEW_WEBKIT2_EXTENSION) + add_library(webkit2_ext SHARED ${WEBKIT2_EXT_FILES}) + wx_set_target_properties(webkit2_ext false) + + # Change output name to match expected name in webview_webkit2.cpp: webkit2_ext* + if(wxUSE_UNICODE) + set(lib_unicode u) + endif() + set_target_properties(webkit2_ext PROPERTIES PREFIX "") + set_target_properties(webkit2_ext PROPERTIES + OUTPUT_NAME "webkit2_ext${lib_unicode}-${wxMAJOR_VERSION}.${wxMINOR_VERSION}" + OUTPUT_NAME_DEBUG "webkit2_ext${lib_unicode}d-${wxMAJOR_VERSION}.${wxMINOR_VERSION}" + ) + + target_include_directories(webkit2_ext PUBLIC + ${LIBSOUP_INCLUDE_DIRS} + ${WEBKIT2_INCLUDE_DIR} + ) + target_link_libraries(webkit2_ext PUBLIC + ${LIBSOUP_LIBRARIES} + ${WEBKIT2_LIBRARIES} + ) + + wx_install(TARGETS webkit2_ext LIBRARY DESTINATION ${WX_WEB_EXTENSIONS_DIRECTORY}) + + add_dependencies(webview webkit2_ext) +endif() diff --git a/build/files b/build/files index fa83ae8e71..7cb2c2234a 100644 --- a/build/files +++ b/build/files @@ -2815,6 +2815,9 @@ WEBVIEW_GTK_SRC = WEBVIEW2_GTK_SRC = src/gtk/webview_webkit2.cpp +WEBVIEW_WEBKIT2_EXTENSION_SRC = + src/gtk/webview_webkit2_extension.cpp + # wxXRC XRC_SRC = diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index 81f9a9a667..656a10f778 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -407,13 +407,14 @@ wxgtk_initialize_web_extensions(WebKitWebContext *context, GVariant *user_data = g_variant_new("(s)", address); // The first value is the location in which the extension is supposed to be - // normally installed, while the other two are used as fallbacks to allow + // normally installed, while the other three are used as fallbacks to allow // running the tests and sample using wxWebView before installing it. const char* const directories[] = { WX_WEB_EXTENSIONS_DIRECTORY, "..", "../..", + "lib", }; const char* dir = NULL; From 271ed4d9909ea9c15195eb7e2e529281ce41b8e6 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 1 Dec 2018 13:42:53 +0100 Subject: [PATCH 121/140] CMake: Support SDL audio back-end Rename UNIX_SOUND_SRC_SDL to UNIX_SOUND_SDL_SRC to match the signature of other variables (ending with _HDR or _SRC). --- build/bakefiles/files.bkl | 4 +- build/bakefiles/plugins.bkl | 2 +- build/cmake/files.cmake | 2 +- build/cmake/init.cmake | 11 ++ build/cmake/lib/core/CMakeLists.txt | 12 ++ build/cmake/modules/FindSDL2.cmake | 175 ++++++++++++++++++++++++++++ build/cmake/options.cmake | 1 + build/files | 2 +- 8 files changed, 204 insertions(+), 5 deletions(-) create mode 100644 build/cmake/modules/FindSDL2.cmake diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 863a733a94..3f84e21ae5 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -3287,7 +3287,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! - + src/unix/sound_sdl.cpp @@ -3708,7 +3708,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! - $(UNIX_SOUND_SRC_SDL) + $(UNIX_SOUND_SDL_SRC) diff --git a/build/bakefiles/plugins.bkl b/build/bakefiles/plugins.bkl index b346903be1..3820980dbb 100644 --- a/build/bakefiles/plugins.bkl +++ b/build/bakefiles/plugins.bkl @@ -7,7 +7,7 @@ - $(UNIX_SOUND_SRC_SDL) + $(UNIX_SOUND_SDL_SRC) $(EXTRALIBS_SDL) diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 2724cc1b68..3111a384c2 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -3057,7 +3057,7 @@ set(OPENGL_OSX_SHARED_SRC src/osx/glcanvas_osx.cpp ) -set(UNIX_SOUND_SRC_SDL +set(UNIX_SOUND_SDL_SRC src/unix/sound_sdl.cpp ) diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 0c9e420f75..70c8369bcc 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -268,4 +268,15 @@ if(wxUSE_GUI) wx_option_force_value(wxUSE_MEDIACTRL OFF) endif() endif() + + if(UNIX AND wxUSE_LIBSDL) + find_package(SDL2) + if(NOT SDL2_FOUND) + find_package(SDL) + endif() + if(NOT SDL2_FOUND AND NOT SDL_FOUND) + message(WARNING "SDL not found, SDL Audio back-end won't be available") + wx_option_force_value(wxUSE_LIBSDL OFF) + endif() + endif() endif() diff --git a/build/cmake/lib/core/CMakeLists.txt b/build/cmake/lib/core/CMakeLists.txt index e0a0a2a52e..38f9677970 100644 --- a/build/cmake/lib/core/CMakeLists.txt +++ b/build/cmake/lib/core/CMakeLists.txt @@ -15,6 +15,9 @@ if(WIN32) wx_append_sources(CORE_SRC BASE_AND_GUI_WIN32) elseif(UNIX) wx_append_sources(CORE_SRC UNIX) + if(wxUSE_LIBSDL) + wx_append_sources(CORE_SRC UNIX_SOUND_SDL) + endif() endif() if(WXMSW) @@ -84,5 +87,14 @@ if(WXGTK AND wxUSE_PRIVATE_FONTS) ${FONTCONFIG_LIBRARIES} ) endif() +if(UNIX AND wxUSE_LIBSDL) + if(SDL2_FOUND) + wx_lib_include_directories(core PUBLIC ${SDL2_INCLUDE_DIR}) + wx_lib_link_libraries(core PUBLIC ${SDL2_LIBRARY}) + elseif(SDL_FOUND) + wx_lib_include_directories(core PUBLIC ${SDL_INCLUDE_DIR}) + wx_lib_link_libraries(core PUBLIC ${SDL_LIBRARY}) + endif() +endif() wx_finalize_lib(core) diff --git a/build/cmake/modules/FindSDL2.cmake b/build/cmake/modules/FindSDL2.cmake new file mode 100644 index 0000000000..3878427d8c --- /dev/null +++ b/build/cmake/modules/FindSDL2.cmake @@ -0,0 +1,175 @@ + +# This module defines +# SDL2_LIBRARY, the name of the library to link against +# SDL2_FOUND, if false, do not try to link to SDL2 +# SDL2_INCLUDE_DIR, where to find SDL.h +# +# This module responds to the the flag: +# SDL2_BUILDING_LIBRARY +# If this is defined, then no SDL2main will be linked in because +# only applications need main(). +# Otherwise, it is assumed you are building an application and this +# module will attempt to locate and set the the proper link flags +# as part of the returned SDL2_LIBRARY variable. +# +# Don't forget to include SDLmain.h and SDLmain.m your project for the +# OS X framework based version. (Other versions link to -lSDL2main which +# this module will try to find on your behalf.) Also for OS X, this +# module will automatically add the -framework Cocoa on your behalf. +# +# +# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration +# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library +# (SDL2.dll, libsdl2.so, SDL2.framework, etc). +# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. +# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value +# as appropriate. These values are used to generate the final SDL2_LIBRARY +# variable, but when these values are unset, SDL2_LIBRARY does not get created. +# +# +# $SDL2DIR is an environment variable that would +# correspond to the ./configure --prefix=$SDL2DIR +# used in building SDL2. +# l.e.galup 9-20-02 +# +# Modified by Eric Wing. +# Added code to assist with automated building by using environmental variables +# and providing a more controlled/consistent search behavior. +# Added new modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). +# Also corrected the header search path to follow "proper" SDL guidelines. +# Added a search for SDL2main which is needed by some platforms. +# Added a search for threads which is needed by some platforms. +# Added needed compile switches for MinGW. +# +# On OSX, this will prefer the Framework version (if found) over others. +# People will have to manually change the cache values of +# SDL2_LIBRARY to override this selection or set the CMake environment +# CMAKE_INCLUDE_PATH to modify the search paths. +# +# Note that the header path has changed from SDL2/SDL.h to just SDL.h +# This needed to change because "proper" SDL convention +# is #include "SDL.h", not . This is done for portability +# reasons because not all systems place things in SDL2/ (see FreeBSD). + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# message("") + +SET(SDL2_SEARCH_PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ${SDL2_PATH} +) + +FIND_PATH(SDL2_INCLUDE_DIR SDL.h + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES include/SDL2 include + PATHS ${SDL2_SEARCH_PATHS} +) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(PATH_SUFFIXES lib64 lib/x64 lib) +else() + set(PATH_SUFFIXES lib/x86 lib) +endif() + +FIND_LIBRARY(SDL2_LIBRARY_TEMP + NAMES SDL2 + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES ${PATH_SUFFIXES} + PATHS ${SDL2_SEARCH_PATHS} +) + +IF(NOT SDL2_BUILDING_LIBRARY) + IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDL2main for compatibility even though they don't + # necessarily need it. + FIND_LIBRARY(SDL2MAIN_LIBRARY + NAMES SDL2main + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES ${PATH_SUFFIXES} + PATHS ${SDL2_SEARCH_PATHS} + ) + ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") +ENDIF(NOT SDL2_BUILDING_LIBRARY) + +# SDL2 may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +IF(NOT APPLE) + FIND_PACKAGE(Threads) +ENDIF(NOT APPLE) + +# MinGW needs an additional link flag, -mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows +IF(MINGW) + SET(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "mwindows for MinGW") +ENDIF(MINGW) + +IF(SDL2_LIBRARY_TEMP) + # For SDL2main + IF(NOT SDL2_BUILDING_LIBRARY) + IF(SDL2MAIN_LIBRARY) + SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(SDL2MAIN_LIBRARY) + ENDIF(NOT SDL2_BUILDING_LIBRARY) + + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + IF(APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") + ENDIF(APPLE) + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + IF(NOT APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(NOT APPLE) + + # For MinGW library + IF(MINGW) + SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(MINGW) + + # Set the final string here so the GUI reflects the final state. + SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") + # Set the temp variable to INTERNAL so it is not seen in the CMake GUI + SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") +ENDIF(SDL2_LIBRARY_TEMP) + +# message("") + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) + +MARK_AS_ADVANCED(SDL2MAIN_LIBRARY SDL2_LIBRARY SDL2_INCLUDE_DIR) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index a972de41da..06ad52725a 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -74,6 +74,7 @@ wx_option(wxUSE_LIBLZMA "use LZMA compression" OFF) set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} wxUSE_LIBLZMA "use liblzma for LZMA compression") wx_option(wxUSE_OPENGL "use OpenGL (or Mesa)") +wx_option(wxUSE_LIBSDL "use SDL for audio on Unix") if(NOT WIN32) wx_option(wxUSE_LIBICONV "use libiconv (character conversion)") diff --git a/build/files b/build/files index 7cb2c2234a..d774633b94 100644 --- a/build/files +++ b/build/files @@ -2997,7 +2997,7 @@ OPENGL_OSX_SHARED_SRC = # Misc plugin sources: -UNIX_SOUND_SRC_SDL = +UNIX_SOUND_SDL_SRC = src/unix/sound_sdl.cpp # wxAUI From 5282f92f8f563ae0472e5cfd384a9952b54c8cc4 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 1 Dec 2018 13:43:48 +0100 Subject: [PATCH 122/140] CMake: Silence OpenGL policy warning --- build/cmake/policies.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/cmake/policies.cmake b/build/cmake/policies.cmake index 46c35011a4..496aae7507 100644 --- a/build/cmake/policies.cmake +++ b/build/cmake/policies.cmake @@ -53,3 +53,8 @@ if(POLICY CMP0067) # Honor language standard in try_compile() source-file signature. cmake_policy(SET CMP0067 NEW) endif() + +if(POLICY CMP0072) + # FindOpenGL prefers GLVND by default when available. + cmake_policy(SET CMP0072 NEW) +endif() From 29666f1d91b8922e27be6f446b5505a18ea76c0d Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 1 Dec 2018 13:44:32 +0100 Subject: [PATCH 123/140] CMake: Fix wxscintilla with precompiled headers and clang The problem also occurs on Linux. --- build/cmake/lib/stc/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/cmake/lib/stc/CMakeLists.txt b/build/cmake/lib/stc/CMakeLists.txt index 27af21bb79..8def395466 100644 --- a/build/cmake/lib/stc/CMakeLists.txt +++ b/build/cmake/lib/stc/CMakeLists.txt @@ -167,10 +167,10 @@ target_compile_definitions(wxscintilla PUBLIC if(wxBUILD_PRECOMP) # The auto-generated header causes undefined members and identifiers in the - # standard c++ headers when using clang on macOS or Windows. + # standard c++ headers when using clang. # Do not disable precompiled headers entirely but use the main Scintilla # header as prefix header so there is at least a small speedup. - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND (APPLE OR WIN32)) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(wxSCINTILLA_PREC_HEADER "${wxSOURCE_DIR}/src/stc/scintilla/include/Scintilla.h") endif() wx_target_enable_precomp(wxscintilla ${wxSCINTILLA_PREC_HEADER}) From c80aecbfc14c9d63d45629da7e44f9fdbb0a2e00 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 2 Dec 2018 17:33:20 +0100 Subject: [PATCH 124/140] CMake: Put include and link commands on one line Use correct check for LIBICONV. --- build/cmake/lib/base/CMakeLists.txt | 4 ++-- build/cmake/lib/core/CMakeLists.txt | 20 +++++--------------- build/cmake/lib/webview/CMakeLists.txt | 4 +--- build/cmake/lib/xml/CMakeLists.txt | 4 +--- 4 files changed, 9 insertions(+), 23 deletions(-) diff --git a/build/cmake/lib/base/CMakeLists.txt b/build/cmake/lib/base/CMakeLists.txt index 0cf6a46860..8f526afebe 100644 --- a/build/cmake/lib/base/CMakeLists.txt +++ b/build/cmake/lib/base/CMakeLists.txt @@ -31,8 +31,8 @@ wx_add_library(base IS_BASE ${BASE_FILES}) if(NOT wxBUILD_MONOLITHIC) wx_lib_compile_definitions(base PRIVATE wxUSE_BASE=1) endif() -if(wxUSE_ZLIB) +if(wxUSE_ZLIB) wx_lib_include_directories(base PRIVATE ${ZLIB_INCLUDE_DIRS}) wx_lib_link_libraries(base PRIVATE ${ZLIB_LIBRARIES}) endif() @@ -48,7 +48,7 @@ if(UNIX AND wxUSE_SECRETSTORE) wx_lib_include_directories(base PRIVATE ${LIBSECRET_INCLUDE_DIRS}) wx_lib_link_libraries(base PRIVATE ${LIBSECRET_LIBRARIES}) endif() -if(wxUSE_LIBICONV AND ICONV_LIBRARIES) +if(wxUSE_LIBICONV AND ICONV_FOUND) wx_lib_include_directories(base PRIVATE ${ICONV_INCLUDE_DIRS}) wx_lib_link_libraries(base PRIVATE ${ICONV_LIBRARIES}) endif() diff --git a/build/cmake/lib/core/CMakeLists.txt b/build/cmake/lib/core/CMakeLists.txt index 38f9677970..54c2810051 100644 --- a/build/cmake/lib/core/CMakeLists.txt +++ b/build/cmake/lib/core/CMakeLists.txt @@ -65,27 +65,17 @@ foreach(lib JPEG PNG TIFF) endforeach() if(WIN32) - wx_lib_link_libraries(core PRIVATE - winmm - ) + wx_lib_link_libraries(core PRIVATE winmm) endif() if(WXOSX_COCOA) - wx_lib_link_libraries(core PUBLIC - "-framework AudioToolbox" - ) + wx_lib_link_libraries(core PUBLIC "-framework AudioToolbox") if(wxUSE_WEBKIT) - wx_lib_link_libraries(core PUBLIC - "-framework WebKit" - ) + wx_lib_link_libraries(core PUBLIC "-framework WebKit") endif() endif() if(WXGTK AND wxUSE_PRIVATE_FONTS) - wx_lib_include_directories(core PUBLIC - ${FONTCONFIG_INCLUDE_DIR} - ) - wx_lib_link_libraries(core PUBLIC - ${FONTCONFIG_LIBRARIES} - ) + wx_lib_include_directories(core PUBLIC ${FONTCONFIG_INCLUDE_DIR}) + wx_lib_link_libraries(core PUBLIC ${FONTCONFIG_LIBRARIES}) endif() if(UNIX AND wxUSE_LIBSDL) if(SDL2_FOUND) diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 8ec75c726d..8de7e67bd2 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -33,9 +33,7 @@ if(wxUSE_WEBVIEW_WEBKIT2) endif() if(APPLE) - wx_lib_link_libraries(webview PUBLIC - "-framework WebKit" - ) + wx_lib_link_libraries(webview PUBLIC "-framework WebKit") elseif(WXGTK) if(LIBSOUP_FOUND) wx_lib_include_directories(webview PUBLIC ${LIBSOUP_INCLUDE_DIRS}) diff --git a/build/cmake/lib/xml/CMakeLists.txt b/build/cmake/lib/xml/CMakeLists.txt index 21173c5ad1..3eaae0b5d1 100644 --- a/build/cmake/lib/xml/CMakeLists.txt +++ b/build/cmake/lib/xml/CMakeLists.txt @@ -11,9 +11,7 @@ include(../../source_groups.cmake) wx_append_sources(XML_FILES XML) wx_add_library(xml IS_BASE ${XML_FILES}) -wx_lib_link_libraries(xml - PRIVATE ${EXPAT_LIBRARIES} - ) +wx_lib_link_libraries(xml PRIVATE ${EXPAT_LIBRARIES}) wx_lib_include_directories(xml PRIVATE ${EXPAT_INCLUDE_DIRS}) wx_finalize_lib(xml) From c0544afcd7b1aca21644d1b5b8d74eb1d5213a26 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 2 Dec 2018 17:34:20 +0100 Subject: [PATCH 125/140] CMake: Improve installation on Linux Install setup header, wx-config and wxrc. Make wx-config executable. Add renamed files and symbolic links to uninstall target. --- build/cmake/install.cmake | 28 ++++++++++++++++++++++++++++ build/cmake/uninstall.cmake.in | 1 + build/cmake/utils/CMakeLists.txt | 18 +++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake index 3e038c8fcf..734a2af88a 100644 --- a/build/cmake/install.cmake +++ b/build/cmake/install.cmake @@ -20,10 +20,32 @@ if(MSVC) DIRECTORY "${wxSOURCE_DIR}/include/msvc" DESTINATION "include") endif() + +# setup header and wx-config if(MSVC OR MINGW) wx_install( DIRECTORY "${wxSETUP_HEADER_PATH}" DESTINATION "lib${wxPLATFORM_LIB_DIR}") +elseif(UNIX) + wx_install( + DIRECTORY "${wxSETUP_HEADER_PATH}" + DESTINATION "lib/wx/include") + + wx_install( + FILES "${wxOUTPUT_DIR}/wx/config/${wxBUILD_FILE_ID}" + DESTINATION "lib/wx/config" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ + ) + + install(DIRECTORY DESTINATION "bin") + install(CODE "execute_process( \ + COMMAND ${CMAKE_COMMAND} -E create_symlink \ + ${CMAKE_INSTALL_PREFIX}/lib/wx/config/${wxBUILD_FILE_ID} \ + ${CMAKE_INSTALL_PREFIX}/bin/wx-config \ + )" + ) endif() # uninstall target @@ -34,6 +56,12 @@ else() endif() if(NOT TARGET ${UNINST_NAME}) + # these files are not added to the install manifest + set(WX_EXTRA_UNINSTALL_FILES + "${CMAKE_INSTALL_PREFIX}/bin/wx-config" + "${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION}" + ) + configure_file( "${wxSOURCE_DIR}/build/cmake/uninstall.cmake.in" "${wxBINARY_DIR}/uninstall.cmake" diff --git a/build/cmake/uninstall.cmake.in b/build/cmake/uninstall.cmake.in index b03059ad52..7d21a385d9 100644 --- a/build/cmake/uninstall.cmake.in +++ b/build/cmake/uninstall.cmake.in @@ -13,6 +13,7 @@ endif() file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") +list(APPEND files @WX_EXTRA_UNINSTALL_FILES@) foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") diff --git a/build/cmake/utils/CMakeLists.txt b/build/cmake/utils/CMakeLists.txt index bf29f72156..a242fdec66 100644 --- a/build/cmake/utils/CMakeLists.txt +++ b/build/cmake/utils/CMakeLists.txt @@ -17,8 +17,24 @@ if(wxUSE_XRC) wx_exe_link_libraries(wxrc xml) endif() wx_exe_link_libraries(wxrc base) - # TODO: install + set_target_properties(wxrc PROPERTIES FOLDER "Utilities") + + if(UNIX) + wx_install(TARGETS wxrc RUNTIME DESTINATION "bin") + install(CODE "execute_process( \ + COMMAND ${CMAKE_COMMAND} -E rename \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION} \ + )" + ) + install(CODE "execute_process( \ + COMMAND ${CMAKE_COMMAND} -E create_symlink \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION} \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc \ + )" + ) + endif() endif() # TODO: build targets for other utils From 8192d507e3b501758ed2fc265ead285652f8ccb4 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 2 Dec 2018 17:34:40 +0100 Subject: [PATCH 126/140] CMake: Fix wx-config include dirs --- build/cmake/config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cmake/config.cmake b/build/cmake/config.cmake index 04db51a020..b89cbac302 100644 --- a/build/cmake/config.cmake +++ b/build/cmake/config.cmake @@ -44,7 +44,7 @@ function(wx_write_config) # TODO: set variables set(includedir "$") - wx_string_append(libdir "{prefix}/include") + wx_string_append(includedir "{prefix}/include") set(libdir "$") wx_string_append(libdir "{exec_prefix}/lib") set(bindir "$") From e984857b0e5a39824824e04574a0f7ca63832ff7 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Mon, 3 Dec 2018 00:20:38 +0100 Subject: [PATCH 127/140] CMake: Improve webview checks Try to match behavior of configure. Fix building webview sample with STC disabled. --- build/cmake/init.cmake | 48 +++++++++++++++++--------- build/cmake/lib/webview/CMakeLists.txt | 4 +-- build/cmake/options.cmake | 1 - build/cmake/samples/CMakeLists.txt | 5 ++- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 70c8369bcc..b5b207924a 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -223,23 +223,39 @@ if(wxUSE_GUI) endif() endif() - if(wxUSE_WEBVIEW AND WXGTK) - find_package(LibSoup) - if(WXGTK2) - find_package(Webkit 1.0) - elseif(WXGTK3) - find_package(Webkit 3.0) - find_package(Webkit2) - if(NOT WEBKIT2_FOUND) - wx_option_force_value(wxUSE_WEBVIEW_WEBKIT2 OFF) + if(wxUSE_WEBVIEW) + if(WXGTK) + if(wxUSE_WEBVIEW_WEBKIT) + find_package(LibSoup) + if(WXGTK2) + find_package(Webkit 1.0) + elseif(WXGTK3) + find_package(Webkit2) + if(NOT WEBKIT2_FOUND) + find_package(Webkit 3.0) + endif() + endif() + endif() + set(wxUSE_WEBVIEW_WEBKIT OFF) + set(wxUSE_WEBVIEW_WEBKIT2 OFF) + if(WEBKIT_FOUND AND LIBSOUP_FOUND) + set(wxUSE_WEBVIEW_WEBKIT ON) + elseif(WEBKIT2_FOUND AND LIBSOUP_FOUND) + set(wxUSE_WEBVIEW_WEBKIT2 ON) + else() + message(WARNING "webkit not found or enabled, wxWebview won't be available") + wx_option_force_value(wxUSE_WEBVIEW OFF) + endif() + elseif(WXMSW) + if(NOT wxUSE_WEBVIEW_IE) + message(WARNING "WebviewIE not found or enabled, wxWebview won't be available") + wx_option_force_value(wxUSE_WEBVIEW OFF) + endif() + elseif(APPLE) + if(NOT wxUSE_WEBVIEW_WEBKIT) + message(WARNING "webkit not found or enabled, wxWebview won't be available") + wx_option_force_value(wxUSE_WEBVIEW OFF) endif() - endif() - if(NOT WEBKIT_FOUND) - wx_option_force_value(wxUSE_WEBVIEW_WEBKIT OFF) - endif() - if((NOT WEBKIT_FOUND AND NOT WEBKIT2_FOUND) OR NOT LIBSOUP_FOUND) - message(WARNING "webkit not found, wxWebview won't be available") - wx_option_force_value(wxUSE_WEBVIEW OFF) endif() endif() diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 8de7e67bd2..ac4caca35e 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -25,7 +25,7 @@ endif() wx_add_library(webview ${WEBVIEW_FILES}) -if(wxUSE_WEBVIEW_WEBKIT2) +if(WXGTK AND wxUSE_WEBVIEW_WEBKIT2) set(WX_WEB_EXTENSIONS_DIRECTORY "lib/wx/${wxMAJOR_VERSION}.${wxMINOR_VERSION}/web-extensions") wx_lib_compile_definitions(webview PRIVATE -DWX_WEB_EXTENSIONS_DIRECTORY="${CMAKE_INSTALL_PREFIX}/${WX_WEB_EXTENSIONS_DIRECTORY}" @@ -53,7 +53,7 @@ wx_finalize_lib(webview) # webkit extension plugin # we can't use (all of the) macros and functions because this library should # always be build as a shared libary, and not included in the monolithic build. -if(WXGTK AND LIBSOUP_FOUND AND wxUSE_WEBVIEW_WEBKIT2) +if(WXGTK AND wxUSE_WEBVIEW_WEBKIT2) wx_append_sources(WEBKIT2_EXT_FILES WEBVIEW_WEBKIT2_EXTENSION) add_library(webkit2_ext SHARED ${WEBKIT2_EXT_FILES}) wx_set_target_properties(webkit2_ext false) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 06ad52725a..1ea8458bda 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -357,7 +357,6 @@ wx_option(wxUSE_DRAGIMAGE "use wxDragImage") wx_option(wxUSE_UIACTIONSIMULATOR "use wxUIActionSimulator (experimental)") wx_option(wxUSE_DC_TRANSFORM_MATRIX "use wxDC::SetTransformMatrix and related") wx_option(wxUSE_WEBVIEW_WEBKIT "use wxWebView WebKit backend") -wx_option(wxUSE_WEBVIEW_WEBKIT2 "use wxWebView WebKit2 backend") if(WIN32 OR APPLE) set(wxUSE_PRIVATE_FONTS_DEFAULT ON) else() diff --git a/build/cmake/samples/CMakeLists.txt b/build/cmake/samples/CMakeLists.txt index 47230283ba..2f8d28070a 100644 --- a/build/cmake/samples/CMakeLists.txt +++ b/build/cmake/samples/CMakeLists.txt @@ -152,7 +152,10 @@ wx_add_sample(typetest typetest.cpp typetest.h) wx_add_sample(uiaction DEPENDS wxUSE_UIACTIONSIMULATOR) wx_add_sample(validate validate.cpp validate.h DEPENDS wxUSE_VALIDATORS) wx_add_sample(vscroll vstest.cpp) -wx_add_sample(webview LIBRARIES webview stc NAME webviewsample DEPENDS wxUSE_WEBVIEW) +wx_add_sample(webview LIBRARIES webview NAME webviewsample DEPENDS wxUSE_WEBVIEW) +if(TARGET webviewsample AND wxUSE_STC) + wx_exe_link_libraries(webviewsample stc) +endif() # widgets Sample set(SAMPLE_WIDGETS_SRC activityindicator.cpp From 58f3dcf780400211e7064095f944617c68291a85 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 3 Dec 2018 14:42:27 +0100 Subject: [PATCH 128/140] fixing macOS sound crash make sure no completion call gets triggered after this point --- src/osx/core/sound.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/osx/core/sound.cpp b/src/osx/core/sound.cpp index f97c11eb2f..1c5ec6e2dc 100644 --- a/src/osx/core/sound.cpp +++ b/src/osx/core/sound.cpp @@ -94,6 +94,7 @@ void wxOSXAudioToolboxSoundData::DoStop() if ( m_playing ) { m_playing = false; + AudioServicesRemoveSystemSoundCompletion(m_soundID); AudioServicesDisposeSystemSoundID (m_soundID); wxSound::SoundStopped(this); From 974b7c09902960c6d607c386be64e8ebe3883076 Mon Sep 17 00:00:00 2001 From: Stefan Ziegler Date: Mon, 3 Dec 2018 14:02:11 +0100 Subject: [PATCH 129/140] Add wxToolbook::EnablePage() Add functions to enable or disable pages inside wxToolbook. Using the new functions you can present disabled icons so that the user can expect more functionality and you do not need to add/remove pages in different states. Closes https://github.com/wxWidgets/wxWidgets/pull/1038 --- docs/changes.txt | 1 + include/wx/toolbook.h | 4 ++++ interface/wx/toolbook.h | 42 +++++++++++++++++++++++++++++++++++++++++ src/generic/toolbkg.cpp | 26 +++++++++++++++++++++++-- 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index b414530c9c..37e3a5e8ac 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -140,6 +140,7 @@ All (GUI): - Add wxDisplay::GetPPI(). - Add wxJoystickEvent::GetButtonOrdinal() (Mick Phillips). - Add wxGraphicsContext::GetWindow() and implement wxGraphicsContext::GetDPI(). +- Add wxToolbook::EnablePage() (Stefan Ziegler). wxGTK: diff --git a/include/wx/toolbook.h b/include/wx/toolbook.h index ecd703cfc2..ee3e018fe0 100644 --- a/include/wx/toolbook.h +++ b/include/wx/toolbook.h @@ -92,6 +92,10 @@ public: // get the underlying toolbar wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; } + // enable/disable a page + bool EnablePage(wxWindow *page, bool enable); + bool EnablePage(size_t page, bool enable); + // must be called in OnIdle or by application to realize the toolbar and // select the initial page. void Realize(); diff --git a/interface/wx/toolbook.h b/interface/wx/toolbook.h index 08d1f45991..ad8447d386 100644 --- a/interface/wx/toolbook.h +++ b/interface/wx/toolbook.h @@ -23,6 +23,9 @@ wxEventType wxEVT_TOOLBOOK_PAGE_CHANGING; refer to that class documentation for now. You can also use the @ref page_samples_notebook to see wxToolbook in action. + One feature of this class not supported by wxBookCtrlBase is the support + for disabling some of the pages, see EnablePage(). + @beginStyleTable @style{wxTBK_BUTTONBAR} Use wxButtonToolBar-based implementation under OS X (ignored under @@ -82,5 +85,44 @@ public: Returns the wxToolBarBase associated with the control. */ wxToolBarBase* GetToolBar() const; + + /** + Enables or disables the specified page. + + Using this function, a page can be disabled when it can't be used, while + still remaining present to let the users know that more functionality is + available, even if currently inaccessible. + + Icons for disabled pages are created by wxBitmap::ConvertToDisabled(). + + @param page + The index of the page. + @param enable + @true to enable the page and @false to disable it. + + @return @true if successful, @false otherwise (currently only if the + index is invalid). + + @since 3.1.2 + */ + bool EnablePage(size_t page, bool enable); + + /** + Enables or disables the specified page. + + This is similar to the overload above, but finds the index of the + specified page. + + @param page + Pointer of a page windows inside the book control. + @param enable + @true to enable the page and @false to disable it. + + @return @true if successful, @false otherwise, e.g. if @a page is not + one of the pages of this control. + + @since 3.1.2 + */ + bool EnablePage(wxWindow *page, bool enable); }; diff --git a/src/generic/toolbkg.cpp b/src/generic/toolbkg.cpp index 07cd9fa962..a7ad0601fb 100644 --- a/src/generic/toolbkg.cpp +++ b/src/generic/toolbkg.cpp @@ -167,7 +167,9 @@ bool wxToolbook::SetPageImage(size_t n, int imageId) if (!GetImageList()) return false; - GetToolBar()->SetToolNormalBitmap(n + 1, GetImageList()->GetBitmap(imageId)); + wxBitmap bmp = GetImageList()->GetBitmap(imageId); + GetToolBar()->SetToolNormalBitmap(n + 1, bmp); + GetToolBar()->SetToolDisabledBitmap(n + 1, bmp.ConvertToDisabled()); return true; } @@ -301,7 +303,7 @@ bool wxToolbook::InsertPage(size_t n, m_maxBitmapSize.y = wxMax(bitmap.GetHeight(), m_maxBitmapSize.y); GetToolBar()->SetToolBitmapSize(m_maxBitmapSize); - GetToolBar()->AddRadioTool(n + 1, text, bitmap, wxNullBitmap, text); + GetToolBar()->AddRadioTool(n + 1, text, bitmap, bitmap.ConvertToDisabled(), text); if (bSelect) { @@ -336,6 +338,26 @@ bool wxToolbook::DeleteAllPages() return wxBookCtrlBase::DeleteAllPages(); } +bool wxToolbook::EnablePage(size_t page, bool enable) +{ + GetToolBar()->EnableTool(page + 1, enable); + if (!enable && GetSelection() == (int)page) + { + AdvanceSelection(); + } + return true; +} + +bool wxToolbook::EnablePage(wxWindow *page, bool enable) +{ + const int pageIndex = FindPage(page); + if (pageIndex == wxNOT_FOUND) + { + return false; + } + return EnablePage(pageIndex, enable); +} + // ---------------------------------------------------------------------------- // wxToolbook events // ---------------------------------------------------------------------------- From 727a100a6ac8815058c37f8827c5c93044166b37 Mon Sep 17 00:00:00 2001 From: Daniel Kulp Date: Thu, 1 Nov 2018 11:02:30 -0400 Subject: [PATCH 130/140] Handle wxEVT_SYS_COLOUR_CHANGED in wxAUI classes Update the colours used when the system theme changes. This is especially important to use the colour scheme compatible with macOS 10.14+ dark mode. Note that this commit is best viewed with "git diff --color-moved". Closes https://github.com/wxWidgets/wxWidgets/pull/916 --- docs/changes.txt | 1 + include/wx/aui/auibar.h | 7 +++ include/wx/aui/auibook.h | 2 + include/wx/aui/dockart.h | 6 +++ include/wx/aui/framemanager.h | 1 + include/wx/aui/tabart.h | 6 +++ src/aui/auibar.cpp | 41 ++++++++++------ src/aui/auibook.cpp | 33 +++++++++++++ src/aui/dockart.cpp | 90 +++++++++++++++++++---------------- src/aui/framemanager.cpp | 8 ++++ src/aui/tabart.cpp | 42 ++++++++-------- 11 files changed, 161 insertions(+), 76 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 37e3a5e8ac..3cf2901ca5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -141,6 +141,7 @@ All (GUI): - Add wxJoystickEvent::GetButtonOrdinal() (Mick Phillips). - Add wxGraphicsContext::GetWindow() and implement wxGraphicsContext::GetDPI(). - Add wxToolbook::EnablePage() (Stefan Ziegler). +- Adapt AUI colours to system colour changes (Daniel Kulp). wxGTK: diff --git a/include/wx/aui/auibar.h b/include/wx/aui/auibar.h index 2ee3c02d24..274757d88e 100644 --- a/include/wx/aui/auibar.h +++ b/include/wx/aui/auibar.h @@ -344,6 +344,10 @@ public: virtual int ShowDropDown( wxWindow* wnd, const wxAuiToolBarItemArray& items) = 0; + + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() {} + }; @@ -429,6 +433,8 @@ public: virtual int ShowDropDown(wxWindow* wnd, const wxAuiToolBarItemArray& items) wxOVERRIDE; + virtual void UpdateColoursFromSystem() wxOVERRIDE; + protected: wxBitmap m_buttonDropDownBmp; @@ -651,6 +657,7 @@ protected: // handlers void OnLeaveWindow(wxMouseEvent& evt); void OnCaptureLost(wxMouseCaptureLostEvent& evt); void OnSetCursor(wxSetCursorEvent& evt); + void OnSysColourChanged(wxSysColourChangedEvent& event); protected: diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index c6d232e48d..2571f7d9ac 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -226,6 +226,7 @@ protected: void OnKillFocus(wxFocusEvent& event); void OnChar(wxKeyEvent& event); void OnCaptureLost(wxMouseCaptureLostEvent& evt); + void OnSysColourChanged(wxSysColourChangedEvent& event); protected: @@ -408,6 +409,7 @@ protected: void OnTabRightUp(wxAuiNotebookEvent& evt); void OnTabBgDClick(wxAuiNotebookEvent& evt); void OnNavigationKeyNotebook(wxNavigationKeyEvent& event); + void OnSysColourChanged(wxSysColourChangedEvent& event); // set selection to the given window (which must be non-NULL and be one of // our pages, otherwise an assert is raised) diff --git a/include/wx/aui/dockart.h b/include/wx/aui/dockart.h index 48ee31bc25..bb931d7acc 100644 --- a/include/wx/aui/dockart.h +++ b/include/wx/aui/dockart.h @@ -76,6 +76,9 @@ public: int buttonState, const wxRect& rect, wxAuiPaneInfo& pane) = 0; + + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() {} }; @@ -136,6 +139,9 @@ public: wxAuiPaneInfo& pane); #endif + virtual void UpdateColoursFromSystem() wxOVERRIDE; + + protected: void DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active); diff --git a/include/wx/aui/framemanager.h b/include/wx/aui/framemanager.h index 300e767125..2e6cf222e3 100644 --- a/include/wx/aui/framemanager.h +++ b/include/wx/aui/framemanager.h @@ -616,6 +616,7 @@ protected: void OnChildFocus(wxChildFocusEvent& evt); void OnHintFadeTimer(wxTimerEvent& evt); void OnFindManager(wxAuiManagerEvent& evt); + void OnSysColourChanged(wxSysColourChangedEvent& event); protected: diff --git a/include/wx/aui/tabart.h b/include/wx/aui/tabart.h index 47efe359e3..f11e75b4ba 100644 --- a/include/wx/aui/tabart.h +++ b/include/wx/aui/tabart.h @@ -109,6 +109,9 @@ public: wxWindow* wnd, const wxAuiNotebookPageArray& pages, const wxSize& requiredBmpSize) = 0; + + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() {} }; @@ -185,6 +188,9 @@ public: const wxAuiNotebookPageArray& pages, const wxSize& requiredBmpSize) wxOVERRIDE; + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() wxOVERRIDE; + protected: wxFont m_normalFont; diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index c0b67db7ae..f31bb456a9 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -124,28 +124,16 @@ const wxColour DISABLED_TEXT_COLOR(DISABLED_TEXT_GREY_HUE, wxAuiGenericToolBarArt::wxAuiGenericToolBarArt() { - m_baseColour = GetBaseColor(); + UpdateColoursFromSystem(); m_flags = 0; m_textOrientation = wxAUI_TBTOOL_TEXT_BOTTOM; - m_highlightColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); m_separatorSize = wxWindow::FromDIP( 7, NULL); m_gripperSize = wxWindow::FromDIP( 7, NULL); m_overflowSize = wxWindow::FromDIP(16, NULL); m_dropdownSize = wxWindow::FromDIP(10, NULL); - wxColor darker1Colour = m_baseColour.ChangeLightness(85); - wxColor darker2Colour = m_baseColour.ChangeLightness(75); - wxColor darker3Colour = m_baseColour.ChangeLightness(60); - wxColor darker4Colour = m_baseColour.ChangeLightness(50); - wxColor darker5Colour = m_baseColour.ChangeLightness(40); - - int pen_width = wxWindow::FromDIP(1, NULL); - m_gripperPen1 = wxPen(darker5Colour, pen_width); - m_gripperPen2 = wxPen(darker3Colour, pen_width); - m_gripperPen3 = wxPen(*wxWHITE, pen_width); - // TODO: Provide x1.5 and x2.0 versions or migrate to SVG. static const unsigned char buttonDropdownBits[] = { 0xe0, 0xf1, 0xfb }; static const unsigned char overflowBits[] = { 0x80, 0xff, 0x80, 0xc1, 0xe3, 0xf7 }; @@ -165,13 +153,27 @@ wxAuiGenericToolBarArt::~wxAuiGenericToolBarArt() { m_font = *wxNORMAL_FONT; } - - wxAuiToolBarArt* wxAuiGenericToolBarArt::Clone() { return static_cast(new wxAuiGenericToolBarArt); } +void wxAuiGenericToolBarArt::UpdateColoursFromSystem() +{ + m_baseColour = GetBaseColor(); + m_highlightColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + wxColor darker1Colour = m_baseColour.ChangeLightness(85); + wxColor darker2Colour = m_baseColour.ChangeLightness(75); + wxColor darker3Colour = m_baseColour.ChangeLightness(60); + wxColor darker4Colour = m_baseColour.ChangeLightness(50); + wxColor darker5Colour = m_baseColour.ChangeLightness(40); + + int pen_width = wxWindow::FromDIP(1, NULL); + m_gripperPen1 = wxPen(darker5Colour, pen_width); + m_gripperPen2 = wxPen(darker3Colour, pen_width); + m_gripperPen3 = wxPen(*wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE), pen_width); +} + void wxAuiGenericToolBarArt::SetFlags(unsigned int flags) { m_flags = flags; @@ -858,6 +860,7 @@ wxBEGIN_EVENT_TABLE(wxAuiToolBar, wxControl) EVT_LEAVE_WINDOW(wxAuiToolBar::OnLeaveWindow) EVT_MOUSE_CAPTURE_LOST(wxAuiToolBar::OnCaptureLost) EVT_SET_CURSOR(wxAuiToolBar::OnSetCursor) + EVT_SYS_COLOUR_CHANGED(wxAuiToolBar::OnSysColourChanged) wxEND_EVENT_TABLE() void wxAuiToolBar::Init() @@ -2428,6 +2431,14 @@ void wxAuiToolBar::UpdateWindowUI(long flags) wxControl::UpdateWindowUI(flags); } +void wxAuiToolBar::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + event.Skip(); + + m_art->UpdateColoursFromSystem(); + Refresh(); +} + void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxAutoBufferedPaintDC dc(this); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index f1298c9997..9bfe2a7589 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -998,6 +998,7 @@ wxBEGIN_EVENT_TABLE(wxAuiTabCtrl, wxControl) EVT_KILL_FOCUS(wxAuiTabCtrl::OnKillFocus) EVT_CHAR(wxAuiTabCtrl::OnChar) EVT_MOUSE_CAPTURE_LOST(wxAuiTabCtrl::OnCaptureLost) + EVT_SYS_COLOUR_CHANGED(wxAuiTabCtrl::OnSysColourChanged) wxEND_EVENT_TABLE() @@ -1028,6 +1029,16 @@ void wxAuiTabCtrl::OnPaint(wxPaintEvent&) Render(&dc, this); } +void wxAuiTabCtrl::OnSysColourChanged(wxSysColourChangedEvent &event) +{ + event.Skip(); + + if (m_art) + { + m_art->UpdateColoursFromSystem(); + } +} + void wxAuiTabCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { } @@ -1669,8 +1680,30 @@ wxBEGIN_EVENT_TABLE(wxAuiNotebook, wxControl) wxEVT_AUINOTEBOOK_BG_DCLICK, wxAuiNotebook::OnTabBgDClick) EVT_NAVIGATION_KEY(wxAuiNotebook::OnNavigationKeyNotebook) + EVT_SYS_COLOUR_CHANGED(wxAuiNotebook::OnSysColourChanged) wxEND_EVENT_TABLE() +void wxAuiNotebook::OnSysColourChanged(wxSysColourChangedEvent &event) +{ + event.Skip(true); + wxAuiTabArt* art = m_tabs.GetArtProvider(); + art->UpdateColoursFromSystem(); + + wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes(); + size_t i, pane_count = all_panes.GetCount(); + for (i = 0; i < pane_count; ++i) + { + wxAuiPaneInfo& pane = all_panes.Item(i); + if (pane.name == wxT("dummy")) + continue; + wxTabFrame* tab_frame = (wxTabFrame*)pane.window; + wxAuiTabCtrl* tabctrl = tab_frame->m_tabs; + tabctrl->GetArtProvider()->UpdateColoursFromSystem(); + tabctrl->Refresh(); + } + Refresh(); +} + void wxAuiNotebook::Init() { m_curPage = -1; diff --git a/src/aui/dockart.cpp b/src/aui/dockart.cpp index 870f5c2d68..7168307302 100644 --- a/src/aui/dockart.cpp +++ b/src/aui/dockart.cpp @@ -156,48 +156,7 @@ wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size) wxAuiDefaultDockArt::wxAuiDefaultDockArt() { -#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON - wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); -#else - wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); -#endif - - // the baseColour is too pale to use as our base colour, - // so darken it a bit -- - if ((255-baseColour.Red()) + - (255-baseColour.Green()) + - (255-baseColour.Blue()) < 60) - { - baseColour = baseColour.ChangeLightness(92); - } - - m_baseColour = baseColour; - wxColor darker1Colour = baseColour.ChangeLightness(85); - wxColor darker2Colour = baseColour.ChangeLightness(75); - wxColor darker3Colour = baseColour.ChangeLightness(60); - //wxColor darker4Colour = baseColour.ChangeLightness(50); - wxColor darker5Colour = baseColour.ChangeLightness(40); - - m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); - m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - m_inactiveCaptionColour = darker1Colour; - m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97); -#ifdef __WXMAC__ - m_inactiveCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT); -#else - m_inactiveCaptionTextColour = *wxBLACK; -#endif - - m_sashBrush = wxBrush(baseColour); - m_backgroundBrush = wxBrush(baseColour); - m_gripperBrush = wxBrush(baseColour); - - m_borderPen = wxPen(darker2Colour); - int pen_width = wxWindow::FromDIP(1, NULL); - m_gripperPen1 = wxPen(darker5Colour, pen_width); - m_gripperPen2 = wxPen(darker3Colour, pen_width); - m_gripperPen3 = wxPen(*wxWHITE, pen_width); + UpdateColoursFromSystem(); #ifdef __WXMAC__ m_captionFont = *wxSMALL_FONT; @@ -296,6 +255,53 @@ wxAuiDefaultDockArt::InitBitmaps () m_activePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_activeCaptionTextColour); } +void wxAuiDefaultDockArt::UpdateColoursFromSystem() +{ +#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON + wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); +#else + wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); +#endif + + // the baseColour is too pale to use as our base colour, + // so darken it a bit -- + if ((255-baseColour.Red()) + + (255-baseColour.Green()) + + (255-baseColour.Blue()) < 60) + { + baseColour = baseColour.ChangeLightness(92); + } + + m_baseColour = baseColour; + wxColor darker1Colour = baseColour.ChangeLightness(85); + wxColor darker2Colour = baseColour.ChangeLightness(75); + wxColor darker3Colour = baseColour.ChangeLightness(60); + //wxColor darker4Colour = baseColour.ChangeLightness(50); + wxColor darker5Colour = baseColour.ChangeLightness(40); + + m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); + m_inactiveCaptionColour = darker1Colour; + m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97); +#ifdef __WXMAC__ + m_inactiveCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT); +#else + m_inactiveCaptionTextColour = *wxBLACK; +#endif + + m_sashBrush = wxBrush(baseColour); + m_backgroundBrush = wxBrush(baseColour); + m_gripperBrush = wxBrush(baseColour); + + m_borderPen = wxPen(darker2Colour); + int pen_width = wxWindow::FromDIP(1, NULL); + m_gripperPen1 = wxPen(darker5Colour, pen_width); + m_gripperPen2 = wxPen(darker3Colour, pen_width); + m_gripperPen3 = wxPen(*wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE), pen_width); + InitBitmaps(); +} + int wxAuiDefaultDockArt::GetMetric(int id) { switch (id) diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index a57599fcb5..6c20bea464 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -604,6 +604,7 @@ wxBEGIN_EVENT_TABLE(wxAuiManager, wxEvtHandler) EVT_MOUSE_CAPTURE_LOST(wxAuiManager::OnCaptureLost) EVT_CHILD_FOCUS(wxAuiManager::OnChildFocus) EVT_AUI_FIND_MANAGER(wxAuiManager::OnFindManager) + EVT_SYS_COLOUR_CHANGED(wxAuiManager::OnSysColourChanged) wxEND_EVENT_TABLE() @@ -648,6 +649,13 @@ wxAuiManager::~wxAuiManager() delete m_art; } +void wxAuiManager::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + m_art->UpdateColoursFromSystem(); + m_frame->Refresh(); + event.Skip(true); +} + // creates a floating frame for the windows wxAuiFloatingFrame* wxAuiManager::CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& paneInfo) diff --git a/src/aui/tabart.cpp b/src/aui/tabart.cpp index 993f6f8605..97667be5fa 100644 --- a/src/aui/tabart.cpp +++ b/src/aui/tabart.cpp @@ -164,6 +164,29 @@ wxAuiGenericTabArt::wxAuiGenericTabArt() m_fixedTabWidth = wxWindow::FromDIP(100, NULL); m_tabCtrlHeight = 0; + UpdateColoursFromSystem(); + + m_activeCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, *wxBLACK); + m_disabledCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxColour(128,128,128)); + + m_activeLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, *wxBLACK); + m_disabledLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxColour(128,128,128)); + + m_activeRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, *wxBLACK); + m_disabledRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxColour(128,128,128)); + + m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK); + m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)); + + m_flags = 0; +} + +wxAuiGenericTabArt::~wxAuiGenericTabArt() +{ +} + +void wxAuiGenericTabArt::UpdateColoursFromSystem() +{ #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); #else @@ -186,24 +209,6 @@ wxAuiGenericTabArt::wxAuiGenericTabArt() m_borderPen = wxPen(borderColour); m_baseColourPen = wxPen(m_baseColour); m_baseColourBrush = wxBrush(m_baseColour); - - m_activeCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, *wxBLACK); - m_disabledCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxColour(128,128,128)); - - m_activeLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, *wxBLACK); - m_disabledLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxColour(128,128,128)); - - m_activeRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, *wxBLACK); - m_disabledRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxColour(128,128,128)); - - m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK); - m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)); - - m_flags = 0; -} - -wxAuiGenericTabArt::~wxAuiGenericTabArt() -{ } wxAuiTabArt* wxAuiGenericTabArt::Clone() @@ -919,7 +924,6 @@ wxAuiSimpleTabArt::wxAuiSimpleTabArt() m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK); m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)); - } wxAuiSimpleTabArt::~wxAuiSimpleTabArt() From dbd46881e6b643d5e1b2b2fa02da8135e3934515 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 4 Dec 2018 15:18:24 +0100 Subject: [PATCH 131/140] Fix links to installation instructions in README-GIT.md The extensions of these files have changed from .txt to .md, see 1b5e3649e51ca84e0ac7eb71a6bf86217197172e Closes #18282. --- README-GIT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-GIT.md b/README-GIT.md index dca9fb2a94..af30263943 100644 --- a/README-GIT.md +++ b/README-GIT.md @@ -13,5 +13,5 @@ control. After doing this, please proceed with the build as with any official release, i.e. follow the instructions in the port-specific files, e.g. -[wxMSW](docs/msw/install.txt), [wxGTK](docs/gtk/install.txt), -[wxOSX](docs/osx/install.txt) and so on. +[wxMSW](docs/msw/install.md), [wxGTK](docs/gtk/install.md), +[wxOSX](docs/osx/install.md) and so on. From 4726819484e1ecf9200a7c6bf3e1eb18625d18da Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Tue, 27 Nov 2018 22:18:22 +0000 Subject: [PATCH 132/140] Rotate wxNotebook tabs label under wxGTK to match other ports wxMSW and wxOSX/Cocoa show the labels vertically for the tabs positioned on the left- or right-hand side of wxNotebook, but wxGTK showed them horizontally. Bring it in sync with the other ports by rotating the labels to draw them vertically as the other ports do in wxGTK too. Closes https://github.com/wxWidgets/wxWidgets/pull/1032 --- src/gtk/notebook.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 31978cb2b0..71bd4d8ec2 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -454,6 +454,12 @@ bool wxNotebook::InsertPage( size_t position, /* set the label text */ pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text))); + + if (m_windowStyle & wxBK_LEFT) + gtk_label_set_angle(GTK_LABEL(pageData->m_label), 90); + if (m_windowStyle & wxBK_RIGHT) + gtk_label_set_angle(GTK_LABEL(pageData->m_label), 270); + gtk_box_pack_end(GTK_BOX(pageData->m_box), pageData->m_label, false, false, m_padding); From 16c121d4d32a3d00c5e773d9ef6b9e25eb8d8d2b Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Wed, 28 Nov 2018 10:07:57 +0000 Subject: [PATCH 133/140] Implement [GS]etLabel() for wxStaticText and wxCheckBox in wxQt This allows the corresponding unit tests to pass. Closes https://github.com/wxWidgets/wxWidgets/pull/1033 --- include/wx/qt/checkbox.h | 3 +++ include/wx/qt/stattext.h | 3 ++- src/qt/checkbox.cpp | 11 +++++++++++ src/qt/stattext.cpp | 5 +++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/wx/qt/checkbox.h b/include/wx/qt/checkbox.h index 6bb328de70..82a28ec14f 100644 --- a/include/wx/qt/checkbox.h +++ b/include/wx/qt/checkbox.h @@ -32,6 +32,9 @@ public: virtual void SetValue(bool value); virtual bool GetValue() const; + virtual void SetLabel(const wxString& label) wxOVERRIDE; + virtual wxString GetLabel() const wxOVERRIDE; + virtual QWidget *GetHandle() const; protected: diff --git a/include/wx/qt/stattext.h b/include/wx/qt/stattext.h index 36f8628aae..513bae3479 100644 --- a/include/wx/qt/stattext.h +++ b/include/wx/qt/stattext.h @@ -30,7 +30,8 @@ public: long style = 0, const wxString &name = wxStaticTextNameStr ); - void SetLabel(const wxString& label); + virtual void SetLabel(const wxString& label) wxOVERRIDE; + virtual wxString GetLabel() const wxOVERRIDE; virtual QWidget *GetHandle() const; diff --git a/src/qt/checkbox.cpp b/src/qt/checkbox.cpp index 48baecf281..c248531f72 100644 --- a/src/qt/checkbox.cpp +++ b/src/qt/checkbox.cpp @@ -130,3 +130,14 @@ QWidget *wxCheckBox::GetHandle() const { return m_qtCheckBox; } + +wxString wxCheckBox::GetLabel() const +{ + return wxQtConvertString( m_qtCheckBox->text() ); +} + +void wxCheckBox::SetLabel(const wxString& label) +{ + m_qtCheckBox->setText( wxQtConvertString(label) ); +} + diff --git a/src/qt/stattext.cpp b/src/qt/stattext.cpp index c60a6fdd36..8e410bfa10 100644 --- a/src/qt/stattext.cpp +++ b/src/qt/stattext.cpp @@ -62,6 +62,11 @@ void wxStaticText::SetLabel(const wxString& label) m_qtLabel->setText( wxQtConvertString( label ) ); } +wxString wxStaticText::GetLabel() const +{ + return wxQtConvertString( m_qtLabel->text() ); +} + QWidget *wxStaticText::GetHandle() const { return m_qtLabel; From 29f771ab826a871bfcb23eba87ca01b0fed3e364 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Wed, 28 Nov 2018 13:11:36 +0000 Subject: [PATCH 134/140] Add support of wxFONTSTYLE_SLANT to wxFont in wxQt Closes https://github.com/wxWidgets/wxWidgets/pull/1034 --- src/qt/font.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/qt/font.cpp b/src/qt/font.cpp index 79e66fc81a..7e328d099a 100644 --- a/src/qt/font.cpp +++ b/src/qt/font.cpp @@ -469,9 +469,18 @@ void wxNativeFontInfo::SetPixelSize(const wxSize& size) void wxNativeFontInfo::SetStyle(wxFontStyle style) { - m_qtFont.setItalic(style == wxFONTSTYLE_ITALIC); -//case wxFONTSTYLE_SLANT: -//case wxFONTSTYLE_NORMAL: + switch(style) + { + case wxFONTSTYLE_ITALIC: + m_qtFont.setStyle(QFont::StyleItalic); + break; + case wxFONTSTYLE_NORMAL: + m_qtFont.setStyle(QFont::StyleNormal); + break; + case wxFONTSTYLE_SLANT: + m_qtFont.setStyle(QFont::StyleOblique); + break; + } } void wxNativeFontInfo::SetNumericWeight(int weight) From 5e089badc06ede3c87a2c55c5478ff84cd167b9c Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Fri, 30 Nov 2018 11:24:26 +0000 Subject: [PATCH 135/140] Fix bitmap accessor for the buttons in wxQt Return the bitmap previously set with SetBitmap(). This fixes unit tests using GetBitmap(). Closes https://github.com/wxWidgets/wxWidgets/pull/1035 --- include/wx/qt/anybutton.h | 4 +++- src/qt/anybutton.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/wx/qt/anybutton.h b/include/wx/qt/anybutton.h index 1d07bc5b3b..f8cc359f97 100644 --- a/include/wx/qt/anybutton.h +++ b/include/wx/qt/anybutton.h @@ -26,11 +26,12 @@ public: // -------------- virtual void SetLabel( const wxString &label ); - virtual void DoSetBitmap(const wxBitmap& bitmap, State which); virtual QWidget *GetHandle() const; protected: + virtual wxBitmap DoGetBitmap(State state) const wxOVERRIDE; + virtual void DoSetBitmap(const wxBitmap& bitmap, State which) wxOVERRIDE; QPushButton *m_qtPushButton; @@ -39,6 +40,7 @@ protected: private: typedef wxAnyButtonBase base_type; + wxBitmap m_bitmap; wxDECLARE_NO_COPY_CLASS(wxAnyButton); }; diff --git a/src/qt/anybutton.cpp b/src/qt/anybutton.cpp index 216b796979..dc56780af2 100644 --- a/src/qt/anybutton.cpp +++ b/src/qt/anybutton.cpp @@ -58,6 +58,8 @@ void wxAnyButton::QtSetBitmap( const wxBitmap &bitmap ) QPixmap *pixmap = bitmap.GetHandle(); m_qtPushButton->setIcon( QIcon( *pixmap )); m_qtPushButton->setIconSize( pixmap->rect().size() ); + + m_bitmap = bitmap; } void wxAnyButton::SetLabel( const wxString &label ) @@ -70,6 +72,11 @@ QWidget *wxAnyButton::GetHandle() const return m_qtPushButton; } +wxBitmap wxAnyButton::DoGetBitmap(State state) const +{ + return state == State_Normal ? m_bitmap : wxNullBitmap; +} + void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which) { switch ( which ) From 94a58121f770620b77d43b7f4559512997949f55 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Mon, 3 Dec 2018 16:02:21 +0000 Subject: [PATCH 136/140] Fix crash on setting the accelerator table in wxQt Check whether m_qtShortcuts is non-null before dereferencing it. Closes https://github.com/wxWidgets/wxWidgets/pull/1040 --- src/qt/window.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 87feb5ecb7..8342db8c74 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -936,13 +936,17 @@ void wxWindowQt::SetAcceleratorTable( const wxAcceleratorTable& accel ) { wxWindowBase::SetAcceleratorTable( accel ); - // Disable previously set accelerators - while ( !m_qtShortcuts->isEmpty() ) - delete m_qtShortcuts->takeFirst(); + if ( m_qtShortcuts ) + { + // Disable previously set accelerators + while ( !m_qtShortcuts->isEmpty() ) + delete m_qtShortcuts->takeFirst(); + + // Create new shortcuts (use GetHandle() so all events inside + // the window are handled, not only in the container subwindow) + delete m_qtShortcuts; + } - // Create new shortcuts (use GetHandle() so all events inside - // the window are handled, not only in the container subwindow) - delete m_qtShortcuts; m_qtShortcuts = accel.ConvertShortcutTable( GetHandle() ); // Connect shortcuts to window From 928b00ad556c9dbd6c34b877aec16ed9462121d6 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Tue, 4 Dec 2018 10:02:39 +0000 Subject: [PATCH 137/140] Fix setting initial value of wxSpinCtrl in wxQt When creating a QSpinBox, the range must be set before setting the initial value as otherwise setting it would fail if it were outside of the default [0, 99] range. This fixes a test failure in the corresponding unit test. Closes https://github.com/wxWidgets/wxWidgets/pull/1041 --- src/qt/spinctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/spinctrl.cpp b/src/qt/spinctrl.cpp index ee0b1e670d..e7cdeddff7 100644 --- a/src/qt/spinctrl.cpp +++ b/src/qt/spinctrl.cpp @@ -42,8 +42,8 @@ bool wxSpinCtrlQt< T, Widget >::Create( wxWindow *parent, wxWindowID id, m_qtSpinBox->setAccelerated(true); // to match gtk behavior - SetValue( initial ); SetRange( min, max ); + SetValue( initial ); SetIncrement( inc ); if ( !value.IsEmpty() ) From f271cc61e8480c6ac319e5d3ea7e845a6bd0ed1c Mon Sep 17 00:00:00 2001 From: Tomay Date: Sat, 1 Dec 2018 14:06:22 +0100 Subject: [PATCH 138/140] Fall back on default margins if the theme doesn't provide them ::GetThemeMargins() may fail if the custom theme being currently used doesn't implement the required functionality, so initialize MARGINS with some reasonable values before calling it, if only in order to avoid using uninitialized (and so wildly wrong) margin values in this case. Closes https://github.com/wxWidgets/wxWidgets/pull/1036 Closes #18278. --- src/msw/anybutton.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index c4c4d11f53..c2daf84c7d 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -524,7 +524,9 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const { wxUxThemeHandle theme(const_cast(this), L"BUTTON"); - MARGINS margins; + // Initialize margins with the default values (at least under + // Windows 7) in case GetThemeMargins() fails. + MARGINS margins = {3, 3, 3, 3}; ::GetThemeMargins(theme, NULL, BP_PUSHBUTTON, PBS_NORMAL, @@ -1148,8 +1150,9 @@ void DrawXPBackground(wxAnyButton *button, HDC hdc, RECT& rectBtn, UINT state) ::DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState, &rectBtn, NULL); - // calculate content area margins - MARGINS margins; + // calculate content area margins, using the defaults in case we fail to + // retrieve the current theme margins + MARGINS margins = {3, 3, 3, 3}; ::GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState, TMT_CONTENTMARGINS, &rectBtn, &margins); ::InflateRect(&rectBtn, -margins.cxLeftWidth, -margins.cyTopHeight); From 729295d02fdd3d62647373f3d329ee67a5517314 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Wed, 5 Dec 2018 14:36:01 +0000 Subject: [PATCH 139/140] Set wxGauge initial value correctly in wxQt The default value of QProgressBar is -1, while wxGauge initial value must be 0, so set it explicitly to fix a unit test failure with wxQt. Closes https://github.com/wxWidgets/wxWidgets/pull/1043 --- src/qt/gauge.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/gauge.cpp b/src/qt/gauge.cpp index ffa1c0963d..8952043db8 100644 --- a/src/qt/gauge.cpp +++ b/src/qt/gauge.cpp @@ -58,6 +58,7 @@ bool wxGauge::Create(wxWindow *parent, m_qtProgressBar->setOrientation( wxQtConvertOrientation( style, wxGA_HORIZONTAL )); m_qtProgressBar->setRange( 0, range ); m_qtProgressBar->setTextVisible( style & wxGA_TEXT ); + m_qtProgressBar->setValue(0); return QtCreateControl( parent, id, pos, size, style, validator, name ); } From e1a702a205a145ff791a8f8097d33e18c86646de Mon Sep 17 00:00:00 2001 From: Stefan Ziegler Date: Wed, 5 Dec 2018 13:14:01 +0100 Subject: [PATCH 140/140] Fix removing and inserting pages in wxToolbook Removing a page from wxToolbook could result in crashes due to dereferencing the now invalid page index. Fix this by not assuming that the page index is the same as its tool ID, but adding functions to explicitly map one to the other. Also fix inserting pages into wxToolbook, which worked as appending them before. Closes https://github.com/wxWidgets/wxWidgets/pull/1042 Closes #18275. --- docs/changes.txt | 1 + include/wx/toolbook.h | 8 +++++ src/generic/toolbkg.cpp | 77 ++++++++++++++++++++++++++++++++--------- 3 files changed, 69 insertions(+), 17 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3cf2901ca5..57a5769bcc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -142,6 +142,7 @@ All (GUI): - Add wxGraphicsContext::GetWindow() and implement wxGraphicsContext::GetDPI(). - Add wxToolbook::EnablePage() (Stefan Ziegler). - Adapt AUI colours to system colour changes (Daniel Kulp). +- Fix removing and inserting pages in wxToolbook (Stefan Ziegler). wxGTK: diff --git a/include/wx/toolbook.h b/include/wx/toolbook.h index ee3e018fe0..fd868226cb 100644 --- a/include/wx/toolbook.h +++ b/include/wx/toolbook.h @@ -123,6 +123,14 @@ private: // common part of all constructors void Init(); + // returns the tool identifier for the specified page + int PageToToolId(size_t page) const; + + // returns the page index for the specified tool ID or + // wxNOT_FOUND if there is no page with that tool ID + int ToolIdToPage(int toolId) const; + + wxDECLARE_EVENT_TABLE(); wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook); }; diff --git a/src/generic/toolbkg.cpp b/src/generic/toolbkg.cpp index a7ad0601fb..38be3659a5 100644 --- a/src/generic/toolbkg.cpp +++ b/src/generic/toolbkg.cpp @@ -42,7 +42,7 @@ wxDEFINE_EVENT( wxEVT_TOOLBOOK_PAGE_CHANGED, wxBookCtrlEvent ); wxBEGIN_EVENT_TABLE(wxToolbook, wxBookCtrlBase) EVT_SIZE(wxToolbook::OnSize) - EVT_TOOL_RANGE(1, 50, wxToolbook::OnToolSelected) + EVT_TOOL(wxID_ANY, wxToolbook::OnToolSelected) EVT_IDLE(wxToolbook::OnIdle) wxEND_EVENT_TABLE() @@ -134,8 +134,8 @@ void wxToolbook::OnSize(wxSizeEvent& event) bool wxToolbook::SetPageText(size_t n, const wxString& strText) { - // Assume tool ids start from 1 - wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1); + int toolId = PageToToolId(n); + wxToolBarToolBase* tool = GetToolBar()->FindById(toolId); if (tool) { tool->SetLabel(strText); @@ -147,7 +147,8 @@ bool wxToolbook::SetPageText(size_t n, const wxString& strText) wxString wxToolbook::GetPageText(size_t n) const { - wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1); + int toolId = PageToToolId(n); + wxToolBarToolBase* tool = GetToolBar()->FindById(toolId); if (tool) return tool->GetLabel(); else @@ -167,9 +168,10 @@ bool wxToolbook::SetPageImage(size_t n, int imageId) if (!GetImageList()) return false; + int toolId = PageToToolId(n); wxBitmap bmp = GetImageList()->GetBitmap(imageId); - GetToolBar()->SetToolNormalBitmap(n + 1, bmp); - GetToolBar()->SetToolDisabledBitmap(n + 1, bmp.ConvertToDisabled()); + GetToolBar()->SetToolNormalBitmap(toolId, bmp); + GetToolBar()->SetToolDisabledBitmap(toolId, bmp.ConvertToDisabled()); return true; } @@ -199,7 +201,8 @@ void wxToolbook::MakeChangedEvent(wxBookCtrlEvent &event) void wxToolbook::UpdateSelectedPage(size_t newsel) { - GetToolBar()->ToggleTool(newsel + 1, true); + int toolId = PageToToolId(newsel); + GetToolBar()->ToggleTool(toolId, true); } // Not part of the wxBookctrl API, but must be called in OnIdle or @@ -302,16 +305,30 @@ bool wxToolbook::InsertPage(size_t n, m_maxBitmapSize.x = wxMax(bitmap.GetWidth(), m_maxBitmapSize.x); m_maxBitmapSize.y = wxMax(bitmap.GetHeight(), m_maxBitmapSize.y); + int toolId = page->GetId(); GetToolBar()->SetToolBitmapSize(m_maxBitmapSize); - GetToolBar()->AddRadioTool(n + 1, text, bitmap, bitmap.ConvertToDisabled(), text); + GetToolBar()->InsertTool(n, toolId, text, bitmap, bitmap.ConvertToDisabled(), wxITEM_RADIO); - if (bSelect) + // fix current selection + if (m_selection == wxNOT_FOUND) { - GetToolBar()->ToggleTool(n, true); + DoShowPage(page, true); m_selection = n; } + else if ((size_t) m_selection >= n) + { + DoShowPage(page, false); + m_selection++; + } else - page->Hide(); + { + DoShowPage(page, false); + } + + if ( bSelect ) + { + SetSelection(n); + } InvalidateBestSize(); return true; @@ -319,11 +336,12 @@ bool wxToolbook::InsertPage(size_t n, wxWindow *wxToolbook::DoRemovePage(size_t page) { + int toolId = PageToToolId(page); wxWindow *win = wxBookCtrlBase::DoRemovePage(page); if ( win ) { - GetToolBar()->DeleteTool(page + 1); + GetToolBar()->DeleteTool(toolId); DoSetSelectionAfterRemoval(page); } @@ -340,7 +358,8 @@ bool wxToolbook::DeleteAllPages() bool wxToolbook::EnablePage(size_t page, bool enable) { - GetToolBar()->EnableTool(page + 1, enable); + int toolId = PageToToolId(page); + GetToolBar()->EnableTool(toolId, enable); if (!enable && GetSelection() == (int)page) { AdvanceSelection(); @@ -358,15 +377,39 @@ bool wxToolbook::EnablePage(wxWindow *page, bool enable) return EnablePage(pageIndex, enable); } +int wxToolbook::PageToToolId(size_t page) const +{ + wxCHECK_MSG(page < GetPageCount(), wxID_NONE, "Invalid page number"); + return GetPage(page)->GetId(); +} + +int wxToolbook::ToolIdToPage(int toolId) const +{ + for (size_t i = 0; i < m_pages.size(); i++) + { + if (m_pages[i]->GetId() == toolId) + { + return (int) i; + } + } + return wxNOT_FOUND; +} + // ---------------------------------------------------------------------------- // wxToolbook events // ---------------------------------------------------------------------------- void wxToolbook::OnToolSelected(wxCommandEvent& event) { - const int selNew = event.GetId() - 1; + // find page for the tool + int page = ToolIdToPage(event.GetId()); + if (page == wxNOT_FOUND) + { + // this happens only of page id has changed afterwards + return; + } - if ( selNew == m_selection ) + if (page == m_selection ) { // this event can only come from our own Select(m_selection) below // which we call when the page change is vetoed, so we should simply @@ -374,10 +417,10 @@ void wxToolbook::OnToolSelected(wxCommandEvent& event) return; } - SetSelection(selNew); + SetSelection(page); // change wasn't allowed, return to previous state - if (m_selection != selNew) + if (m_selection != page) { GetToolBar()->ToggleTool(m_selection, false); }