From c3e0999b06defc9055adbc54e222af8bc10b8691 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 21 Feb 2012 05:39:00 +0000 Subject: [PATCH] Rewrite DoPaint, FullPaint and add FullPaintDC to help deal with flicker problems and to be more like how the other Scintilla ports are working now. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70659 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/stc/ScintillaWX.cpp | 49 +++++++++++++++++++++++++++-------------- src/stc/ScintillaWX.h | 1 + src/stc/stc.cpp | 2 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 8241114798..7433b1d641 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -733,25 +733,47 @@ sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) { paintState = painting; - Surface* surfaceWindow = Surface::Allocate(); - surfaceWindow->Init(dc, wMain.GetID()); - rcPaint = PRectangleFromwxRect(rect); - PRectangle rcClient = GetClientRectangle(); - paintingAllText = rcPaint.Contains(rcClient); - - ClipChildren(*dc, rcPaint); - Paint(surfaceWindow, rcPaint); + AutoSurface surfaceWindow(dc, this); + if (surfaceWindow) { + rcPaint = PRectangleFromwxRect(rect); + PRectangle rcClient = GetClientRectangle(); + paintingAllText = rcPaint.Contains(rcClient); + + ClipChildren(*dc, rcPaint); + Paint(surfaceWindow, rcPaint); + surfaceWindow->Release(); + } - delete surfaceWindow; if (paintState == paintAbandoned) { // Painting area was insufficient to cover new styling or brace // highlight positions - FullPaint(); + FullPaintDC(dc); + } + paintState = notPainting; +} + + +// Force the whole window to be repainted +void ScintillaWX::FullPaint() { + wxClientDC dc(stc); + FullPaintDC(&dc); +} + + +void ScintillaWX::FullPaintDC(wxDC* dc) { + paintState = painting; + rcPaint = GetClientRectangle(); + paintingAllText = true; + AutoSurface surfaceWindow(dc, this); + if (surfaceWindow) { + Paint(surfaceWindow, rcPaint); + surfaceWindow->Release(); } paintState = notPainting; } + void ScintillaWX::DoHScroll(int type, int pos) { int xPos = xOffset; PRectangle rcText = GetTextRectangle(); @@ -1080,13 +1102,6 @@ void ScintillaWX::DoDragLeave() { #endif // wxUSE_DRAG_AND_DROP //---------------------------------------------------------------------- -// Force the whole window to be repainted -void ScintillaWX::FullPaint() { - stc->Refresh(false); - stc->Update(); -} - - void ScintillaWX::DoScrollToLine(int line) { ScrollTo(line); } diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index df5ad6748a..701f288169 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -166,6 +166,7 @@ public: // helpers void FullPaint(); + void FullPaintDC(wxDC* dc); bool CanPaste(); bool GetHideSelection() { return hideSelection; } void DoScrollToLine(int line); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 307321bb83..02e366969a 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -210,7 +210,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, SetInitialSize(size); // Reduces flicker on GTK+/X11 - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); // Make sure it can take the focus SetCanFocus(true); -- 2.45.2