X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/936170f4070cb6eac25cbcd0f0015b03a607cec7..05e0b047d879cdbfade7f2ab346c0acdf3e29f96:/src/generic/regiong.cpp diff --git a/src/generic/regiong.cpp b/src/generic/regiong.cpp index 99fd7cb8b8..9511c83df2 100644 --- a/src/generic/regiong.cpp +++ b/src/generic/regiong.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: generic/region.cpp +// Name: src/generic/region.cpp // Purpose: generic wxRegion class // Author: David Elliott // Modified by: @@ -9,8 +9,19 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#include "wx/generic/region.h" -#include "wx/utils.h" + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/region.h" + +#ifndef WX_PRECOMP + #include "wx/utils.h" +#endif // ======================================================================== // Classes to interface with X.org code @@ -28,6 +39,7 @@ struct REGION public: // Default constructor initializes nothing REGION() {} + REGION(const wxRect& rect) { rects = &extents; @@ -38,7 +50,11 @@ public: extents.y2 = rect.y + rect.height; size = 1; } - BoxPtr GetBox(int i) { if(irects = ( BOX * )malloc( (unsigned) sizeof( BOX )))) { + + temp->rects = ( BOX * )malloc( (unsigned) sizeof( BOX )); + + if (!temp->rects) + { free((char *) temp); return (Region) NULL; } @@ -623,10 +612,7 @@ XCreateRegion(void) return( temp ); } -bool REGION:: -XClipBox( - Region r, - wxRect *rect) +bool REGION::XClipBox(Region r, wxRect *rect) { rect->x = r->extents.x1; rect->y = r->extents.y1; @@ -859,9 +845,10 @@ miRegionCopy( { BOX *prevRects = dstrgn->rects; - if (! (dstrgn->rects = (BOX *) + dstrgn->rects = (BOX *) realloc((char *) dstrgn->rects, - (unsigned) rgn->numRects * (sizeof(BOX))))) + (unsigned) rgn->numRects * (sizeof(BOX))); + if (!dstrgn->rects) { free(prevRects); return; @@ -1128,8 +1115,10 @@ miRegionOp( */ newReg->size = wxMax(reg1->numRects,reg2->numRects) * 2; - if (! (newReg->rects = (BoxPtr) - malloc ((unsigned) (sizeof(BoxRec) * newReg->size)))) { + newReg->rects = (BoxPtr)malloc((unsigned) (sizeof(BoxRec) * newReg->size)); + + if (!newReg->rects) + { newReg->size = 0; return; } @@ -1758,11 +1747,7 @@ miSubtractO ( *----------------------------------------------------------------------- */ -bool REGION:: -XSubtractRegion( - Region regM, - Region regS, - register Region regD) +bool REGION::XSubtractRegion(Region regM, Region regS, register Region regD) { /* check for trivial reject */ if ( (!(regM->numRects)) || (!(regS->numRects)) || @@ -1786,13 +1771,16 @@ XSubtractRegion( return true; } -bool REGION:: -XXorRegion(Region sra, Region srb, Region dr) +bool REGION::XXorRegion(Region sra, Region srb, Region dr) { - Region tra, trb; + Region tra = XCreateRegion(); + + wxCHECK_MSG( tra, false, wxT("region not created") ); + + Region trb = XCreateRegion(); + + wxCHECK_MSG( trb, false, wxT("region not created") ); - if ((! (tra = XCreateRegion())) || (! (trb = XCreateRegion()))) - return 0; (void) XSubtractRegion(sra,srb,tra); (void) XSubtractRegion(srb,sra,trb); (void) XUnionRegion(tra,trb,dr); @@ -1805,9 +1793,7 @@ XXorRegion(Region sra, Region srb, Region dr) * Check to see if the region is empty. Assumes a region is passed * as a parameter */ -bool REGION:: -XEmptyRegion( - Region r) +bool REGION::XEmptyRegion(Region r) { if( r->numRects == 0 ) return true; else return false; @@ -1816,8 +1802,7 @@ XEmptyRegion( /* * Check to see if two regions are equal */ -bool REGION:: -XEqualRegion(Region r1, Region r2) +bool REGION::XEqualRegion(Region r1, Region r2) { int i; @@ -1836,10 +1821,7 @@ XEqualRegion(Region r1, Region r2) return true; } -bool REGION:: -XPointInRegion( - Region pRegion, - int x, int y) +bool REGION::XPointInRegion(Region pRegion, int x, int y) { int i; @@ -1855,11 +1837,10 @@ XPointInRegion( return false; } -wxRegionContain REGION:: -XRectInRegion( - register Region region, - int rx, int ry, - unsigned int rwidth, unsigned int rheight) +wxRegionContain REGION::XRectInRegion(register Region region, + int rx, int ry, + unsigned int rwidth, + unsigned int rheight) { register BoxPtr pbox; register BoxPtr pboxEnd; @@ -1936,4 +1917,3 @@ XRectInRegion( return(partIn ? ((ry < prect->y2) ? wxPartRegion : wxInRegion) : wxOutRegion); } -