refine Windows gui-update repairs

svn: r9827
This commit is contained in:
Matthew Flatt 2008-05-13 20:14:17 +00:00
parent 49175b1402
commit 9ac4aa9e62
4 changed files with 59 additions and 9 deletions

View File

@ -22,7 +22,7 @@ class wxCanvas: public wxbCanvas
{
public:
wxWindow *combo;
int need_update;
HRGN need_update;
wxCanvas(void);
wxCanvas(wxWindow *parent, int x=-1, int y=-1, int width=-1, int height=-1,

View File

@ -36,6 +36,7 @@ class wxDC: public wxbDC
int window_ext_x;
int window_ext_y;
HRGN limit_rgn;
int canvas_scroll_dx, canvas_scroll_dy;
wxCanvas *canvas;

View File

@ -127,6 +127,10 @@ wxCanvas::~wxCanvas (void)
wxwmReleaseDC(wnd->handle, dc);
delete wx_dc;
}
if (need_update) {
DeleteObject(need_update);
need_update = NULL;
}
}
void wxCanvas::GetSize(int *width, int *height)
@ -669,6 +673,7 @@ BOOL wxCanvasWnd::OnPaint(void)
if (GetUpdateRgn(handle, tRgn, FALSE)) {
PAINTSTRUCT ps;
HRGN need_update;
BeginPaint(handle, &ps);
@ -676,7 +681,14 @@ BOOL wxCanvasWnd::OnPaint(void)
now we queue an event. The need_update flag
avoids multiple updats with we queue multiple
events before the first is handled. */
((wxCanvas *)wx_window)->need_update = 1;
need_update = ((wxCanvas *)wx_window)->need_update;
if (!need_update) {
need_update = CreateRectRgn(0,0,0,0);
((wxCanvas *)wx_window)->need_update = need_update;
}
CombineRgn(need_update, tRgn, need_update, RGN_OR);
MrEdQueuePaint(wx_window);
EndPaint(handle, &ps);
@ -694,7 +706,30 @@ BOOL wxCanvasWnd::OnPaint(void)
void wxCanvas::DoPaint()
{
if (need_update) {
need_update = 0;
OnPaint();
RECT r;
if (GetRgnBox(need_update, &r) != NULLREGION) {
wxDC *dc;
HDC hdc;
HRGN paint_rgn;
paint_rgn = CreateRectRgn(0,0,0,0);
CombineRgn(paint_rgn, need_update, paint_rgn, RGN_COPY);
SetRectRgn(need_update, 0, 0, 0, 0);
dc = GetDC();
dc->limit_rgn = paint_rgn;
hdc = dc->ThisDC(FALSE);
dc->DoClipping(hdc);
dc->DoneDC(hdc);
OnPaint();
dc->limit_rgn = NULL;
hdc = dc->ThisDC(FALSE);
dc->DoClipping(hdc);
dc->DoneDC(hdc);
DeleteObject(paint_rgn);
}
}
}

View File

@ -437,17 +437,31 @@ void wxDC::DoClipping(HDC dc)
HRGN rgn;
rgn = clipping->GetRgn();
if (rgn) {
SelectClipRgn(dc, rgn);
OffsetClipRgn(dc, canvas_scroll_dx, canvas_scroll_dy);
if (limit_rgn) {
HRGN together_rgn;
together_rgn = CreateRectRgn(0,0,0,0);
CombineRgn(together_rgn, rgn, together_rgn, RGN_COPY);
OffsetRgn(together_rgn, canvas_scroll_dx, canvas_scroll_dy);
CombineRgn(together_rgn, limit_rgn, together_rgn, RGN_AND);
SelectClipRgn(dc, together_rgn);
DeleteObject(together_rgn);
} else {
SelectClipRgn(dc, rgn);
OffsetClipRgn(dc, canvas_scroll_dx, canvas_scroll_dy);
}
} else {
if (!empty_rgn)
empty_rgn = CreateRectRgn(0, 0, 0, 0);
SelectClipRgn(dc, empty_rgn);
}
} else {
if (!full_rgn)
full_rgn = CreateRectRgn(0, 0, 32000, 32000);
SelectClipRgn(dc, full_rgn);
if (limit_rgn) {
SelectClipRgn(dc, limit_rgn);
} else {
if (!full_rgn)
full_rgn = CreateRectRgn(0, 0, 32000, 32000);
SelectClipRgn(dc, full_rgn);
}
}
}