// Intersect & push a new clip rectangle: void Fl_Device::push_clip(int x, int y, int w, int h) { Region r; if (w > 0 && h > 0) { fl_transform(x,y); r = XRectangleRegion(x, y, w, h); Region current = rstack[rstackptr]; if (current) { #ifndef _WIN32 Region temp = XCreateRegion(); XIntersectRegion(current, r, temp); XDestroyRegion(r); r = temp; #else CombineRgn(r,r,current,RGN_AND); #endif } } // make empty clip region: else { #ifndef _WIN32 r = XCreateRegion(); #else r = CreateRectRgn(0,0,0,0); #endif } if (rstackptr < STACK_MAX) rstack[++rstackptr] = r; fl_restore_clip(); }
// Replace the top of the clip stack: void fl_clip_region(Region r) { Region oldr = rstack[rstackptr]; if(oldr) XDestroyRegion(oldr); rstack[rstackptr] = r; fl_restore_clip(); }
// make there be no clip (used by fl_begin_offscreen() only!) void Fl_Device::push_no_clip() { // this does not test maximum so that this is guaranteed to work, // there is one extra slot at the top of the stack. rstack[++rstackptr] = 0; /*if (rstackptr < STACK_MAX)*/ fl_restore_clip(); }
// pop back to previous clip: void Fl_Device::pop_clip() { if (rstackptr > 0) { Region oldr = rstack[rstackptr--]; if (oldr) XDestroyRegion(oldr); fl_restore_clip(); } }
// Replace top of stack with top of stack minus this rectangle: void Fl_Device::clip_out(int x, int y, int w, int h) { if (w <= 0 || h <= 0) return; Region current = rstack[rstackptr]; // current must not be zero, you must push a rectangle first. I // return without doing anything because that makes some old fltk code work: if (!current) return; fl_transform(x,y); Region r = XRectangleRegion(x, y, w, h); #ifndef _WIN32 Region temp = XCreateRegion(); XSubtractRegion(current, r, temp); XDestroyRegion(r); XDestroyRegion(current); rstack[rstackptr] = temp; #else CombineRgn(current,current,r,RGN_DIFF); DeleteObject(r); #endif fl_restore_clip(); }
FL_EXPORT_C(void,flc_restore_clip)( ){ fl_restore_clip(); }