]> git.saurik.com Git - wxWidgets.git/commitdiff
Rewrite DoPaint, FullPaint and add FullPaintDC to help deal with flicker problems...
authorRobin Dunn <robin@alldunn.com>
Tue, 21 Feb 2012 05:39:00 +0000 (05:39 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 21 Feb 2012 05:39:00 +0000 (05:39 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70659 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/stc/ScintillaWX.cpp
src/stc/ScintillaWX.h
src/stc/stc.cpp

index 8241114798dd8bf894d46374691d748a259240a2..7433b1d641499274713a4b1fe8a3bd23b4233686 100644 (file)
@@ -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);
 }
index df5ad6748a0857c31258dda85bfd2144e132788a..701f28816965086a7a1a1b3a989948aa7bc6ced2 100644 (file)
@@ -166,6 +166,7 @@ public:
 
     // helpers
     void FullPaint();
+    void FullPaintDC(wxDC* dc);
     bool CanPaste();
     bool GetHideSelection() { return hideSelection; }
     void DoScrollToLine(int line);
index 307321bb835dd6711b40d3bdab147008a335c36b..02e366969a7455e56eee90878b93dc82ffdc6d85 100644 (file)
@@ -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);