From b401dfbdac41fd54b409cf2a747c322570881cd7 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 8 Feb 2022 09:56:36 -0800 Subject: [PATCH] Use wxOverlay::IsNative() rather than wxHAS_NATIVE_OVERLAY --- include/wx/generic/caret.h | 8 ----- include/wx/generic/dragimgg.h | 11 ------ src/generic/caret.cpp | 51 ++++++++++++++-------------- src/generic/dragimgg.cpp | 63 +++++++++++++++++------------------ 4 files changed, 56 insertions(+), 77 deletions(-) diff --git a/include/wx/generic/caret.h b/include/wx/generic/caret.h index de9117c656..7223983297 100644 --- a/include/wx/generic/caret.h +++ b/include/wx/generic/caret.h @@ -15,10 +15,6 @@ #include "wx/dc.h" #include "wx/overlay.h" -#ifdef wxHAS_NATIVE_OVERLAY - #define wxHAS_CARET_USING_OVERLAYS -#endif - class WXDLLIMPEXP_FWD_CORE wxCaret; class WXDLLIMPEXP_CORE wxCaretTimer : public wxTimer @@ -75,17 +71,13 @@ private: // GTK specific initialization void InitGeneric(); -#ifdef wxHAS_CARET_USING_OVERLAYS // the overlay for displaying the caret wxOverlay m_overlay; -#else // the bitmap holding the part of window hidden by the caret when it was // at (m_xOld, m_yOld) wxBitmap m_bmpUnderCaret; int m_xOld, m_yOld; -#endif - wxCaretTimer m_timer; bool m_blinkedOut, // true => caret hidden right now m_hasFocus; // true => our window has focus diff --git a/include/wx/generic/dragimgg.h b/include/wx/generic/dragimgg.h index 71ffd8aef9..4c54243631 100644 --- a/include/wx/generic/dragimgg.h +++ b/include/wx/generic/dragimgg.h @@ -144,14 +144,9 @@ public: // Attributes //////////////////////////////////////////////////////////////////////////// -#ifdef wxHAS_NATIVE_OVERLAY - // backing store is not used when native overlays are - void SetBackingBitmap(wxBitmap* WXUNUSED(bitmap)) { } -#else // For efficiency, tell wxGenericDragImage to use a bitmap that's already // created (e.g. from last drag) void SetBackingBitmap(wxBitmap* bitmap) { m_pBackingBitmap = bitmap; } -#endif // wxHAS_NATIVE_OVERLAY/!wxHAS_NATIVE_OVERLAY // Operations //////////////////////////////////////////////////////////////////////////// @@ -234,19 +229,13 @@ protected: bool m_isShown; wxWindow* m_window; wxDC* m_windowDC; - -#ifdef wxHAS_NATIVE_OVERLAY wxOverlay m_overlay; - wxDCOverlay* m_dcOverlay; -#else // Stores the window contents while we're dragging the image around wxBitmap m_backingBitmap; wxBitmap* m_pBackingBitmap; // Pointer to existing backing bitmap // (pass to wxGenericDragImage as an efficiency measure) // A temporary bitmap for repairing/redrawing wxBitmap m_repairBitmap; -#endif // !wxHAS_NATIVE_OVERLAY - wxRect m_boundingRect; bool m_fullScreen; diff --git a/src/generic/caret.cpp b/src/generic/caret.cpp index 4b3bb6c3a4..2be3938f6a 100644 --- a/src/generic/caret.cpp +++ b/src/generic/caret.cpp @@ -97,12 +97,10 @@ void wxCaret::InitGeneric() { m_hasFocus = true; m_blinkedOut = true; -#ifndef wxHAS_CARET_USING_OVERLAYS m_xOld = m_yOld = -1; - if (m_width && m_height) + if (!m_overlay.IsNative() && m_width && m_height) m_bmpUnderCaret.Create(m_width, m_height); -#endif } wxCaret::~wxCaret() @@ -141,9 +139,12 @@ void wxCaret::DoHide() void wxCaret::DoMove() { -#ifdef wxHAS_CARET_USING_OVERLAYS - m_overlay.Reset(); -#endif + if (m_overlay.IsNative()) + { + m_overlay.Reset(); + return; + } + if ( IsVisible() ) { if ( !m_blinkedOut ) @@ -168,15 +169,17 @@ void wxCaret::DoSize() m_countVisible = 0; DoHide(); } -#ifdef wxHAS_CARET_USING_OVERLAYS - m_overlay.Reset(); -#else - // Change bitmap size - if (m_width && m_height) - m_bmpUnderCaret = wxBitmap(m_width, m_height); + + if (m_overlay.IsNative()) + m_overlay.Reset(); else - m_bmpUnderCaret = wxBitmap(); -#endif + { + // Change bitmap size + m_bmpUnderCaret.UnRef(); + if (m_width && m_height) + m_bmpUnderCaret.Create(m_width, m_height); + } + if (countVisible > 0) { m_countVisible = countVisible; @@ -229,18 +232,17 @@ void wxCaret::Blink() void wxCaret::Refresh() { wxClientDC dcWin(GetWindow()); -// this is the new code, switch to 0 if this gives problems -#ifdef wxHAS_CARET_USING_OVERLAYS - wxDCOverlay dcOverlay( m_overlay, &dcWin, m_x, m_y, m_width , m_height ); - if ( m_blinkedOut ) + if (m_overlay.IsNative()) { - dcOverlay.Clear(); + wxDCOverlay dcOverlay(m_overlay, &dcWin, m_x, m_y, m_width, m_height); + if (m_blinkedOut) + dcOverlay.Clear(); + else + DoDraw(&dcWin, GetWindow()); + + return; } - else - { - DoDraw( &dcWin, GetWindow() ); - } -#else + wxMemoryDC dcMem; dcMem.SelectObject(m_bmpUnderCaret); if ( m_blinkedOut ) @@ -268,7 +270,6 @@ void wxCaret::Refresh() // and draw the caret there DoDraw(&dcWin, GetWindow()); } -#endif } void wxCaret::DoDraw(wxDC *dc, wxWindow* win) diff --git a/src/generic/dragimgg.cpp b/src/generic/dragimgg.cpp index 16273875c0..e6efaec8fc 100644 --- a/src/generic/dragimgg.cpp +++ b/src/generic/dragimgg.cpp @@ -65,11 +65,7 @@ void wxGenericDragImage::Init() m_windowDC = NULL; m_window = NULL; m_fullScreen = false; -#ifdef wxHAS_NATIVE_OVERLAY - m_dcOverlay = NULL; -#else m_pBackingBitmap = NULL; -#endif } // Attributes @@ -227,12 +223,13 @@ bool wxGenericDragImage::BeginDrag(const wxPoint& hotspot, } } -#ifndef wxHAS_NATIVE_OVERLAY - wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap); + if (!m_overlay.IsNative()) + { + wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap); - if (!backing->IsOk() || (backing->GetWidth() < clientSize.x || backing->GetHeight() < clientSize.y)) - (*backing) = wxBitmap(clientSize.x, clientSize.y); -#endif // !wxHAS_NATIVE_OVERLAY + if (!backing->IsOk() || (backing->GetWidth() < clientSize.x || backing->GetHeight() < clientSize.y)) + (*backing) = wxBitmap(clientSize.x, clientSize.y); + } if (!m_fullScreen) { @@ -295,17 +292,15 @@ bool wxGenericDragImage::EndDrag() if (m_windowDC) { -#ifdef wxHAS_NATIVE_OVERLAY - m_overlay.Reset(); -#else - m_windowDC->DestroyClippingRegion(); -#endif + if (m_overlay.IsNative()) + m_overlay.Reset(); + else + m_windowDC->DestroyClippingRegion(); + wxDELETE(m_windowDC); } -#ifndef wxHAS_NATIVE_OVERLAY m_repairBitmap = wxNullBitmap; -#endif return true; } @@ -347,16 +342,17 @@ bool wxGenericDragImage::Show() // This is where we restore the backing bitmap, in case // something has changed on the window. -#ifndef wxHAS_NATIVE_OVERLAY - wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap); - wxMemoryDC memDC; - memDC.SelectObject(* backing); + if (!m_overlay.IsNative()) + { + wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap); + wxMemoryDC memDC; + memDC.SelectObject(* backing); - UpdateBackingFromWindow(* m_windowDC, memDC, m_boundingRect, wxRect(0, 0, m_boundingRect.width, m_boundingRect.height)); + UpdateBackingFromWindow(* m_windowDC, memDC, m_boundingRect, wxRect(0, 0, m_boundingRect.width, m_boundingRect.height)); - //memDC.Blit(0, 0, m_boundingRect.width, m_boundingRect.height, m_windowDC, m_boundingRect.x, m_boundingRect.y); - memDC.SelectObject(wxNullBitmap); -#endif // !wxHAS_NATIVE_OVERLAY + //memDC.Blit(0, 0, m_boundingRect.width, m_boundingRect.height, m_windowDC, m_boundingRect.x, m_boundingRect.y); + memDC.SelectObject(wxNullBitmap); + } RedrawImage(m_position - m_offset, m_position - m_offset, false, true); } @@ -399,15 +395,17 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, if (!m_windowDC) return false; -#ifdef wxHAS_NATIVE_OVERLAY - wxUnusedVar(oldPos); + if (m_overlay.IsNative()) + { + wxDCOverlay dcoverlay( m_overlay, (wxWindowDC*) m_windowDC ) ; + if ( eraseOld ) + dcoverlay.Clear() ; + if (drawNew) + DoDrawImage(*m_windowDC, newPos); + + return true; + } - wxDCOverlay dcoverlay( m_overlay, (wxWindowDC*) m_windowDC ) ; - if ( eraseOld ) - dcoverlay.Clear() ; - if (drawNew) - DoDrawImage(*m_windowDC, newPos); -#else // !wxHAS_NATIVE_OVERLAY wxBitmap* backing = (m_pBackingBitmap ? m_pBackingBitmap : (wxBitmap*) & m_backingBitmap); if (!backing->IsOk()) return false; @@ -473,7 +471,6 @@ bool wxGenericDragImage::RedrawImage(const wxPoint& oldPos, memDCTemp.SelectObject(wxNullBitmap); memDC.SelectObject(wxNullBitmap); -#endif // wxHAS_NATIVE_OVERLAY/!wxHAS_NATIVE_OVERLAY return true; }