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
This commit is contained in:
Robin Dunn
2012-02-21 05:39:00 +00:00
parent c0e5edf548
commit c3e0999b06
3 changed files with 33 additions and 17 deletions

View 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) { void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
paintState = painting; paintState = painting;
Surface* surfaceWindow = Surface::Allocate(); AutoSurface surfaceWindow(dc, this);
surfaceWindow->Init(dc, wMain.GetID()); if (surfaceWindow) {
rcPaint = PRectangleFromwxRect(rect); rcPaint = PRectangleFromwxRect(rect);
PRectangle rcClient = GetClientRectangle(); PRectangle rcClient = GetClientRectangle();
paintingAllText = rcPaint.Contains(rcClient); paintingAllText = rcPaint.Contains(rcClient);
ClipChildren(*dc, rcPaint); ClipChildren(*dc, rcPaint);
Paint(surfaceWindow, rcPaint); Paint(surfaceWindow, rcPaint);
surfaceWindow->Release();
}
delete surfaceWindow;
if (paintState == paintAbandoned) { if (paintState == paintAbandoned) {
// Painting area was insufficient to cover new styling or brace // Painting area was insufficient to cover new styling or brace
// highlight positions // highlight positions
FullPaint(); FullPaintDC(dc);
} }
paintState = notPainting; 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) { void ScintillaWX::DoHScroll(int type, int pos) {
int xPos = xOffset; int xPos = xOffset;
PRectangle rcText = GetTextRectangle(); PRectangle rcText = GetTextRectangle();
@@ -1080,13 +1102,6 @@ void ScintillaWX::DoDragLeave() {
#endif // wxUSE_DRAG_AND_DROP #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) { void ScintillaWX::DoScrollToLine(int line) {
ScrollTo(line); ScrollTo(line);
} }

View File

@@ -166,6 +166,7 @@ public:
// helpers // helpers
void FullPaint(); void FullPaint();
void FullPaintDC(wxDC* dc);
bool CanPaste(); bool CanPaste();
bool GetHideSelection() { return hideSelection; } bool GetHideSelection() { return hideSelection; }
void DoScrollToLine(int line); void DoScrollToLine(int line);

View File

@@ -210,7 +210,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent,
SetInitialSize(size); SetInitialSize(size);
// Reduces flicker on GTK+/X11 // Reduces flicker on GTK+/X11
SetBackgroundStyle(wxBG_STYLE_CUSTOM); SetBackgroundStyle(wxBG_STYLE_PAINT);
// Make sure it can take the focus // Make sure it can take the focus
SetCanFocus(true); SetCanFocus(true);