repair refrech clipping, and clip only for transparent canvases (because the editor probably doesn't work right with clipping)

svn: r9833
This commit is contained in:
Matthew Flatt 2008-05-14 20:07:58 +00:00
parent 77d67718bc
commit c19191d35e
3 changed files with 42 additions and 15 deletions

View File

@ -38,7 +38,7 @@ class wxCanvasDC: public wxbCanvasDC
int pixmapWidth; int pixmapWidth;
int pixmapHeight; int pixmapHeight;
RgnHandle current_reg, onpaint_reg; RgnHandle current_reg, onpaint_reg, clip_reg;
int current_pen_join; int current_pen_join;
int current_pen_cap; int current_pen_cap;

View File

@ -869,12 +869,20 @@ void wxCanvas::DoPaint(void)
if (EmptyRgn(needs_update)) if (EmptyRgn(needs_update))
return; return;
rgn = NewRgn(); if (cStyle & wxTRANSPARENT_WIN)
rgn = NewRgn();
else
rgn = NULL;
if (rgn) { if (rgn) {
CopyRgn(needs_update, rgn); CopyRgn(needs_update, rgn);
SetRectRgn(needs_update, 0, 0, 0, 0); SetRectRgn(needs_update, 0, 0, 0, 0);
wx_dc->onpaint_reg = rgn; if (wx_dc->clip_reg) {
/* FIXME: nested on-paint... */
}
wx_dc->clip_reg = rgn;
wx_dc->SetCanvasClipping(); wx_dc->SetCanvasClipping();
} else {
SetRectRgn(needs_update, 0, 0, 0, 0);
} }
} else } else
rgn = NULL; rgn = NULL;
@ -886,20 +894,24 @@ void wxCanvas::DoPaint(void)
RGBColor pixel; RGBColor pixel;
pixel = bgcol->pixel; pixel = bgcol->pixel;
SetCurrentDC(); SetCurrentDC();
if (rgn)
SetClip(rgn);
GetThemeDrawingState(&s); GetThemeDrawingState(&s);
GetControlBounds(cPaintControl, &itemRect); GetControlBounds(cPaintControl, &itemRect);
RGBBackColor(&pixel); RGBBackColor(&pixel);
BackPat(GetWhitePattern()); BackPat(GetWhitePattern());
EraseRect(&itemRect); EraseRect(&itemRect);
SetThemeDrawingState(s, TRUE); SetThemeDrawingState(s, TRUE);
if (rgn)
cMacDC->setCurrentUser(NULL);
} }
OnPaint(); OnPaint();
if (rgn) { if (rgn) {
wx_dc->onpaint_reg = NULL; wx_dc->clip_reg = NULL;
wx_dc->SetCanvasClipping(); wx_dc->SetCanvasClipping();
DisposeRgn(rgn); DisposeRgn(rgn);
} }

View File

@ -70,8 +70,9 @@ void wxCanvasDC::Init(wxCanvas* the_canvas)
pixmapWidth = 0; pixmapWidth = 0;
pixmapHeight = 0; pixmapHeight = 0;
current_reg = NULL ; current_reg = NULL;
onpaint_reg = NULL ; onpaint_reg = NULL;
clip_reg = NULL;
min_x = 0; min_y = 0; max_x = 0; max_y = 0; min_x = 0; min_y = 0; max_x = 0; max_y = 0;
@ -135,6 +136,10 @@ wxCanvasDC::~wxCanvasDC(void)
::DisposeRgn(onpaint_reg); ::DisposeRgn(onpaint_reg);
onpaint_reg = NULL; onpaint_reg = NULL;
} }
if (clip_reg) {
::DisposeRgn(clip_reg);
clip_reg = NULL;
}
canvas = NULL; canvas = NULL;
if (reset_chain == this) { if (reset_chain == this) {
@ -279,7 +284,7 @@ void wxCanvasDC::SetCanvasClipping(void)
if (current_reg) { if (current_reg) {
::DisposeRgn(current_reg); ::DisposeRgn(current_reg);
} }
if (clipping || onpaint_reg) { if (clipping || onpaint_reg || clip_reg) {
current_reg = ::NewRgn(); current_reg = ::NewRgn();
CheckMemOK(current_reg); CheckMemOK(current_reg);
} else } else
@ -287,18 +292,22 @@ void wxCanvasDC::SetCanvasClipping(void)
if (clipping && !clipping->rgn) { if (clipping && !clipping->rgn) {
/* NULL rgn pointer means the empty region */ /* NULL rgn pointer means the empty region */
if (!current_reg) {
current_reg = ::NewRgn();
CheckMemOK(current_reg);
}
} else if (clipping) { } else if (clipping) {
::CopyRgn(clipping->rgn, current_reg); ::CopyRgn(clipping->rgn, current_reg);
::OffsetRgn(current_reg, auto_device_origin_x, auto_device_origin_y); ::OffsetRgn(current_reg, auto_device_origin_x, auto_device_origin_y);
if (onpaint_reg) { if (onpaint_reg) {
::SectRgn(current_reg, onpaint_reg, current_reg) ; ::SectRgn(current_reg, onpaint_reg, current_reg);
}
if (clip_reg) {
::SectRgn(current_reg, clip_reg, current_reg);
} }
} else if (onpaint_reg) { } else if (onpaint_reg) {
::CopyRgn(onpaint_reg, current_reg); ::CopyRgn(onpaint_reg, current_reg);
if (clip_reg) {
::SectRgn(current_reg, clip_reg, current_reg);
}
} else if (clip_reg) {
::CopyRgn(clip_reg, current_reg);
} }
theCurrentUser = cMacDC->currentUser(); theCurrentUser = cMacDC->currentUser();
@ -956,11 +965,17 @@ CGContextRef wxCanvasDC::GetCG()
/* Leave the region empty */ /* Leave the region empty */
} else { } else {
if (clipRgn) { if (clipRgn) {
if (onpaint_reg) { if (onpaint_reg || clip_reg) {
RgnHandle visRgn; RgnHandle visRgn;
visRgn = NewRgn(); visRgn = NewRgn();
if (visRgn) { if (visRgn) {
::CopyRgn(onpaint_reg, clipRgn); // GetPortClipRegion(qdp, clipRgn); if (onpaint_reg) {
::CopyRgn(onpaint_reg, clipRgn);
if (clip_reg)
::SectRgn(current_reg, clip_reg, current_reg);
} else {
::CopyRgn(clip_reg, clipRgn);
}
::OffsetRgn(clipRgn, gdx, gdy); ::OffsetRgn(clipRgn, gdx, gdy);
GetPortVisibleRegion(qdp, visRgn); GetPortVisibleRegion(qdp, visRgn);
SectRgn(clipRgn, visRgn, clipRgn); SectRgn(clipRgn, visRgn, clipRgn);