+ // Get all the rectangles from the region, convert the individual
+ // rectangles to "the other" coordinate system and reassemble a
+ // region from the rectangles, to be feed into m_updateRegion.
+ //
+ // FIXME: This is a bad hack since OS/2 API specifies that rectangles
+ // passed into GpiSetRegion must not have Bottom > Top,
+ // however, at first sight, it _seems_ to work nonetheless.
+ //
+ RGNRECT vRgnData;
+ PRECTL pUpdateRects = NULL;
+ vRgnData.ulDirection = RECTDIR_LFRT_TOPBOT;
+ if (::GpiQueryRegionRects( hPS // Pres space
+ ,hRgn // Handle of region to query
+ ,NULL // Return all RECTs
+ ,&vRgnData // Will contain number or RECTs in region
+ ,NULL // NULL to return number of RECTs
+ ))
+ {
+ pUpdateRects = new RECTL[vRgnData.crcReturned];
+ vRgnData.crc = vRgnData.crcReturned;
+ vRgnData.ircStart = 1;
+ if (::GpiQueryRegionRects( hPS // Pres space of source
+ ,hRgn // Handle of source region
+ ,NULL // Return all RECTs
+ ,&vRgnData // Operations set to return rects
+ ,pUpdateRects // Will contain the actual RECTS
+ ))
+ {
+ int height;
+ RECT vRect;
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
+ height = vRect.yTop;
+
+ for(size_t i = 0; i < vRgnData.crc; i++)
+ {
+ int rectHeight;
+ rectHeight = pUpdateRects[i].yTop - pUpdateRects[i].yBottom;
+ pUpdateRects[i].yTop = height - pUpdateRects[i].yTop;
+ pUpdateRects[i].yBottom = pUpdateRects[i].yTop + rectHeight;
+ }
+ ::GpiSetRegion(hPS, hRgn, vRgnData.crc, pUpdateRects);
+ delete [] pUpdateRects;
+ }
+ }
+