From 1314ec77123d892fc17971b043f1d477c9c8750f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Oct 2024 15:32:12 +0200 Subject: [PATCH 1/4] Remove unused mentions of wxScreenDC from the samples It wasn't really used anywhere, but still appeared in the samples. --- samples/dragimag/dragimag.cpp | 17 ----------------- samples/help/doc/wx34.htm | 2 -- 2 files changed, 19 deletions(-) diff --git a/samples/dragimag/dragimag.cpp b/samples/dragimag/dragimag.cpp index 22a77158b5..e71c9542d7 100644 --- a/samples/dragimag/dragimag.cpp +++ b/samples/dragimag/dragimag.cpp @@ -398,23 +398,6 @@ bool MyApp::OnInit() } } -#if 0 - // Under GTK, this demonstrates that - // wxScreenDC only gets the root window content. - // We need to be able to copy the overall content - // for full-screen dragging to work. - int w, h; - wxDisplaySize(& w, & h); - wxBitmap bitmap(w, h); - - wxScreenDC dc; - wxMemoryDC memDC; - memDC.SelectObject(bitmap); - memDC.Blit(0, 0, w, h, & dc, 0, 0); - memDC.SelectObject(wxNullBitmap); - m_background = bitmap; -#endif - frame->Show( true ); return true; diff --git a/samples/help/doc/wx34.htm b/samples/help/doc/wx34.htm index 79a2521d87..67a38b3325 100644 --- a/samples/help/doc/wx34.htm +++ b/samples/help/doc/wx34.htm @@ -496,8 +496,6 @@ wxStaticBoxSizer
-wxScreenDC
- wxScrollBar
wxScrollWinEvent
From 78ff18875d3f1472361cabc0bbc6004520546afa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Oct 2024 15:43:06 +0200 Subject: [PATCH 2/4] Remove calls to wxScreenDC::{Start,End}DrawingOnTop() These functions don't do anything anyhow. --- src/generic/sashwin.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/generic/sashwin.cpp b/src/generic/sashwin.cpp index bf37d8a75f..b1440bb0fb 100644 --- a/src/generic/sashwin.cpp +++ b/src/generic/sashwin.cpp @@ -114,8 +114,6 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event) !wxDynamicCast(parent, wxFrame)) parent = parent->GetParent(); - wxScreenDC::StartDrawingOnTop(parent); - // We don't say we're dragging yet; we leave that // decision for the Dragging() branch, to ensure // the user has dragged a little bit. @@ -149,7 +147,6 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event) ReleaseMouse(); m_mouseCaptured = false; - wxScreenDC::EndDrawingOnTop(); m_dragMode = wxSASH_DRAG_NONE; m_draggingEdge = wxSASH_NONE; } @@ -164,10 +161,6 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event) // Erase old tracker DrawSashTracker(m_draggingEdge, m_oldX, m_oldY); - // End drawing on top (frees the window used for drawing - // over the screen) - wxScreenDC::EndDrawingOnTop(); - int w, h; GetSize(&w, &h); int xp, yp; From 3543cb4663364bd25d4eed291586e463a880b02e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Oct 2024 15:44:10 +0200 Subject: [PATCH 3/4] Stop using wxScreenDC in GetDPIHelper() Use wxDisplay to get the main display DPI instead. --- src/common/wincmn.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index c89cb0260a..f4a7cac71b 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -38,7 +38,6 @@ #include "wx/statusbr.h" #include "wx/toolbar.h" #include "wx/dcclient.h" - #include "wx/dcscreen.h" #include "wx/scrolbar.h" #include "wx/layout.h" #include "wx/sizer.h" @@ -2905,7 +2904,7 @@ static wxSize GetDPIHelper(const wxWindowBase* w) if ( w ) dpi = w->GetDPI(); if ( !dpi.x || !dpi.y ) - dpi = wxScreenDC().GetPPI(); + dpi = wxDisplay().GetPPI(); if ( !dpi.x || !dpi.y ) dpi = wxDisplay::GetStdPPI(); From 9c4a376367d3a18bb250c2a9501495312cbe436b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Oct 2024 15:45:02 +0200 Subject: [PATCH 4/4] Document that wxScreenDC doesn't work in more places Try to make it as clear as possible that this class shouldn't be used any longer without formally deprecating it (as it does still work in wxMSW and, also, is still used in some of our own code). --- docs/doxygen/mainpages/cat_classes.h | 8 +++++--- include/wx/dcscreen.h | 1 + interface/wx/dcclient.h | 6 +++--- interface/wx/dcscreen.h | 2 ++ interface/wx/dragimag.h | 3 +++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/doxygen/mainpages/cat_classes.h b/docs/doxygen/mainpages/cat_classes.h index ffcbf1acf6..e310947434 100644 --- a/docs/doxygen/mainpages/cat_classes.h +++ b/docs/doxygen/mainpages/cat_classes.h @@ -292,11 +292,13 @@ Related Overviews: @ref overview_dc @li wxBufferedPaintDC: A helper device context for double buffered drawing inside @b OnPaint(). @li wxClientDC: A device context to access the client area outside - @b OnPaint() events + @b OnPaint() events (doesn't work on many modern systems, deprecated). @li wxPaintDC: A device context to access the client area inside @b OnPaint() events -@li wxWindowDC: A device context to access the non-client area -@li wxScreenDC: A device context to access the entire screen +@li wxWindowDC: A device context to access the non-client area (Windows-only, + deprecated). +@li wxScreenDC: A device context to access the entire screen (doesn't work on + many modern systems, deprecated). @li wxDC: The device context base class @li wxMemoryDC: A device context for drawing into bitmaps @li wxMetafileDC: A device context for drawing into metafiles diff --git a/include/wx/dcscreen.h b/include/wx/dcscreen.h index 21bdb984c9..b297838159 100644 --- a/include/wx/dcscreen.h +++ b/include/wx/dcscreen.h @@ -13,6 +13,7 @@ #include "wx/defs.h" #include "wx/dc.h" +// This class is obsolete and doesn't work, don't use it. class WXDLLIMPEXP_CORE wxScreenDC : public wxDC { public: diff --git a/interface/wx/dcclient.h b/interface/wx/dcclient.h index b21d6eaa8c..38e8d425fe 100644 --- a/interface/wx/dcclient.h +++ b/interface/wx/dcclient.h @@ -24,7 +24,7 @@ @library{wxcore} @category{dc} - @see wxDC, wxClientDC, wxMemoryDC, wxWindowDC, wxScreenDC + @see wxDC, wxMemoryDC */ class wxPaintDC : public wxClientDC { @@ -66,7 +66,7 @@ public: @library{wxcore} @category{dc} - @see wxDC, wxMemoryDC, wxPaintDC, wxWindowDC, wxScreenDC + @see wxDC, wxMemoryDC, wxPaintDC, wxWindowDC */ class wxClientDC : public wxWindowDC { @@ -120,7 +120,7 @@ public: @library{wxcore} @category{dc} - @see wxDC, wxMemoryDC, wxPaintDC, wxClientDC, wxScreenDC + @see wxDC, wxMemoryDC, wxPaintDC, wxClientDC */ class wxWindowDC : public wxDC { diff --git a/interface/wx/dcscreen.h b/interface/wx/dcscreen.h index 64570bf133..6165a2716d 100644 --- a/interface/wx/dcscreen.h +++ b/interface/wx/dcscreen.h @@ -12,6 +12,8 @@ Please don't use this class in the new code, as it doesn't work on modern systems any longer and using it is not guaranteed to have any effect at all. + Use wxDisplay for getting information about the screen and wxOverlay for + temporarily drawing over a window. A wxScreenDC can be used to paint on the screen. This should normally be constructed as a temporary stack object; don't store a wxScreenDC object. diff --git a/interface/wx/dragimag.h b/interface/wx/dragimag.h index c6752abd95..d8dafb5b03 100644 --- a/interface/wx/dragimag.h +++ b/interface/wx/dragimag.h @@ -15,6 +15,9 @@ platforms, wxGenericDragImage is used. Applications may also prefer to use wxGenericDragImage on Windows, too. + @note wxGenericDragImage implementation uses wxScreenDC and so doesn't work + on the platforms where wxScreenDC doesn't work, e.g. modern macOS versions. + To use this class, when you wish to start dragging an image, create a wxDragImage object and store it somewhere you can access it as the drag progresses. Call BeginDrag() to start, and EndDrag() to stop the drag. To