- wxRect availableSpace(wxPoint(0, 0), GetClientSize());
- if (GetBuffer().GetDirty())
- {
- GetBuffer().Layout(dc, availableSpace, wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
- GetBuffer().SetDirty(false);
- SetupScrollbars();
- PositionCaret();
+ // Paint the background
+ PaintBackground(dc);
+
+ wxRegion dirtyRegion = GetUpdateRegion();
+
+ wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize());
+ wxRect availableSpace(GetClientSize());
+ if (GetBuffer().GetDirty())
+ {
+ GetBuffer().Layout(dc, availableSpace, wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
+ GetBuffer().SetDirty(false);
+ SetupScrollbars();
+ }
+
+ GetBuffer().Draw(dc, GetBuffer().GetRange(), GetSelectionRange(), drawingArea, 0 /* descent */, 0 /* flags */);