wxClientDC::wxClientDC(wxWindow *window) { m_window = window ; wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; if (!rootwindow) return; WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; wxPoint origin = window->GetClientAreaOrigin() ; wxSize size = window->GetClientSize() ; int x , y ; x = origin.x ; y = origin.y ; window->MacWindowToRootWindow( &x , &y ) ; m_macLocalOrigin.x = x ; m_macLocalOrigin.y = y ; SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; m_macPort = UMAGetWindowPort( windowref ) ; m_ok = TRUE ; SetBackground(window->MacGetBackgroundBrush()); SetFont( window->GetFont() ) ; }
/**************************************************************************** Hacks to glue AGL to an HIView ***************************************************************************/ QRegion qt_mac_get_widget_rgn(const QWidget *widget) { if(!widget->isVisible() || widget->isMinimized()) return QRegion(); const QRect wrect = QRect(qt_mac_posInWindow(widget), widget->size()); if(!wrect.isValid()) return QRegion(); RgnHandle macr = qt_mac_get_rgn(); GetControlRegion((HIViewRef)widget->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, wrect.x(), wrect.y()); QRegion ret = qt_mac_convert_mac_region(macr); QPoint clip_pos = wrect.topLeft(); for(const QWidget *last_clip = 0, *clip = widget; clip; last_clip = clip, clip = clip->parentWidget()) { if(clip != widget) { GetControlRegion((HIViewRef)clip->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, clip_pos.x(), clip_pos.y()); ret &= qt_mac_convert_mac_region(macr); } const QObjectList &children = clip->children(); for(int i = children.size()-1; i >= 0; --i) { if(QWidget *child = qobject_cast<QWidget*>(children.at(i))) { if(child == last_clip) break; // This check may seem weird, but when we are using a unified toolbar // The widget is actually being owned by that toolbar and not by Qt. // This means that the geometry it reports will be wrong // and will accidentally cause problems when calculating the region // So, it is better to skip these widgets since they aren't the hierarchy // anyway. if (HIViewGetSuperview(HIViewRef(child->winId())) != HIViewRef(clip->winId())) continue; if(child->isVisible() && !child->isMinimized() && !child->isTopLevel()) { const QRect childRect = QRect(clip_pos+child->pos(), child->size()); if(childRect.isValid() && wrect.intersects(childRect)) { GetControlRegion((HIViewRef)child->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, childRect.x(), childRect.y()); ret -= qt_mac_convert_mac_region(macr); } } } } if(clip->isWindow()) break; clip_pos -= clip->pos(); } qt_mac_dispose_rgn(macr); return ret; }
void Win32Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc, int ySrc, int xDest, int yDest, int width, int height ) { // check and adapt to source if needed if( !checkBoundaries( 0, 0, rGraphics.getWidth(), rGraphics.getHeight(), xSrc, ySrc, width, height ) ) { msg_Err( getIntf(), "nothing to draw from graphics source" ); return; } // check destination if( !checkBoundaries( 0, 0, m_width, m_height, xDest, yDest, width, height ) ) { msg_Err( getIntf(), "out of reach destination! pls, debug your skin" ); return; } // Create the mask for transparency HRGN mask = CreateRectRgn( xSrc, ySrc, xSrc + width, ySrc + height ); CombineRgn( mask, ((Win32Graphics&)rGraphics).getMask(), mask, RGN_AND ); OffsetRgn( mask, xDest - xSrc, yDest - ySrc ); // Copy the image HDC srcDC = ((Win32Graphics&)rGraphics).getDC(); SelectClipRgn( m_hDC, mask ); BitBlt( m_hDC, xDest, yDest, width, height, srcDC, xSrc, ySrc, SRCCOPY ); // Add the source mask to the mask of the graphics CombineRgn( m_mask, mask, m_mask, RGN_OR ); DeleteObject( mask ); }
// Create a DC representing the whole screen wxScreenDC::wxScreenDC() { m_macPort = CreateNewPort() ; GrafPtr port ; GetPort( &port ) ; SetPort( (GrafPtr) m_macPort ) ; Point pt = { 0,0 } ; LocalToGlobal( &pt ) ; SetPort( port ) ; m_macLocalOrigin.x = -pt.h ; m_macLocalOrigin.y = -pt.v ; #if wxMAC_USE_CORE_GRAPHICS m_macLocalOriginInPort = m_macLocalOrigin ; #endif BitMap screenBits; GetQDGlobalsScreenBits( &screenBits ); m_minX = screenBits.bounds.left ; SInt16 height ; GetThemeMenuBarHeight( &height ) ; m_minY = screenBits.bounds.top + height ; m_maxX = screenBits.bounds.right ; m_maxY = screenBits.bounds.bottom ; #if wxMAC_USE_CORE_GRAPHICS m_graphicContext = new wxMacCGContext( port ) ; #else MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; #endif m_ok = TRUE ; }
void Win32Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc, int ySrc, int xDest, int yDest, int width, int height ) { if( width == -1 ) { width = rGraphics.getWidth(); } if( height == -1 ) { height = rGraphics.getHeight(); } // Create the mask for transparency HRGN mask = CreateRectRgn( xSrc, ySrc, xSrc + width, ySrc + height ); CombineRgn( mask, ((Win32Graphics&)rGraphics).getMask(), mask, RGN_AND ); OffsetRgn( mask, xDest - xSrc, yDest - ySrc ); // Copy the image HDC srcDC = ((Win32Graphics&)rGraphics).getDC(); SelectClipRgn( m_hDC, mask ); BitBlt( m_hDC, xDest, yDest, width, height, srcDC, xSrc, ySrc, SRCCOPY ); // Add the source mask to the mask of the graphics CombineRgn( m_mask, mask, m_mask, RGN_OR ); DeleteObject( mask ); }
LRESULT OverlayWindow::onMouseMove(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (((MainWindow *)_parent)->getCaptureMode() == 2 && _isSelecting) { POINT p; GetCursorPos(&p); int x, y, width, height; RECT r = getRect(); HRGN overlayRgn = CreateRectRgn(0, 0, r.right, r.bottom); width = p.x - _firstPoint.x; height = p.y - _firstPoint.y; if (width < 0) { width = -width; x = p.x; } else { x = _firstPoint.x; } if (height < 0) { height = -height; y = p.y; } else { y = _firstPoint.y; } HRGN rgn = CreateRectRgn(0, 0, width, height); SetWindowRgn(_selection->getHandle(), rgn, TRUE); rgn = CreateRectRgn(0, 0, width, height); OffsetRgn(rgn, x, y); CombineRgn(overlayRgn, overlayRgn, rgn, RGN_DIFF); SetWindowRgn(_handle, overlayRgn, FALSE); _selection->move(x, y, width, height, false); _selection->show(SW_SHOW); } return 0; }
// Return true if region is empty FXbool FXRegion::empty() const { #ifdef WIN32 return OffsetRgn((HRGN)region,0,0)==NULLREGION; #else return XEmptyRegion((Region)region); #endif }
pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) { OSStatus status = noErr ; switch( iMessage ) { case kControlMsgSetUpBackground : { wxControl* wx = (wxControl*) GetControlReference( iControl ) ; if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) { wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ; #if TARGET_CARBON // under classic this would lead to partial redraws RgnHandle clip = NewRgn() ; int x = 0 , y = 0; wx->MacWindowToRootWindow( &x,&y ) ; CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ; OffsetRgn( clip , x , y ) ; SetClip( clip ) ; DisposeRgn( clip ) ; #endif } else { status = paramErr ; } } break ; default : status = paramErr ; break ; } return status ; }
static int winAddRgn (WindowPtr pWin, pointer data) { int iX, iY, iWidth, iHeight, iBorder; HRGN hRgn = *(HRGN*)data; HRGN hRgnWin; winWindowPriv(pWin); /* If pWin is not Root */ if (pWin->parent != NULL) { #if CYGDEBUG ErrorF ("winAddRgn ()\n"); #endif if (pWin->mapped) { iBorder = wBorderWidth (pWin); iX = pWin->drawable.x - iBorder; iY = pWin->drawable.y - iBorder; iWidth = pWin->drawable.width + iBorder * 2; iHeight = pWin->drawable.height + iBorder * 2; hRgnWin = CreateRectRgn (0, 0, iWidth, iHeight); if (hRgnWin == NULL) { ErrorF ("winAddRgn - CreateRectRgn () failed\n"); ErrorF (" Rect %d %d %d %d\n", iX, iY, iX + iWidth, iY + iHeight); } if (pWinPriv->hRgn) { if (CombineRgn (hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND) == ERROR) { ErrorF ("winAddRgn - CombineRgn () failed\n"); } } OffsetRgn (hRgnWin, iX, iY); if (CombineRgn (hRgn, hRgn, hRgnWin, RGN_OR) == ERROR) { ErrorF ("winAddRgn - CombineRgn () failed\n"); } DeleteObject (hRgnWin); } return WT_DONTWALKCHILDREN; } else { return WT_WALKCHILDREN; } }
// Offset region by dx,dy FXRegion& FXRegion::offset(FXint dx,FXint dy){ #ifdef WIN32 OffsetRgn((HRGN)region,dx,dy); #else XOffsetRegion((Region)region,dx,dy); #endif return *this; }
/* region is passed in client coords (win32 api doc bug)*/ int WINAPI ExtSelectClipRgn(HDC hdc, HRGN hrgn, int fnMode) { HRGN newrgn; if(!hdc) return ERROR; if(hdc->region != (MWRGNOBJ *)hrgn) { /* combine region if not null*/ if(hrgn) { newrgn = CreateRectRgn(0, 0, 0, 0); /* * Temporarily convert region from * client coords to screen coords, since * hwnd->update is kept in screen coords. */ OffsetRgn(hrgn, hdc->hwnd->clirect.left, hdc->hwnd->clirect.top); if(fnMode == RGN_COPY) CombineRgn(newrgn, hrgn, NULL, fnMode); else CombineRgn(newrgn, (HRGN)hdc->region, hrgn,fnMode); /* convert passed region back to client coords*/ OffsetRgn(hrgn, -hdc->hwnd->clirect.left, -hdc->hwnd->clirect.top); hrgn = newrgn; } DeleteObject((HRGN)hdc->region); hdc->region = (MWRGNOBJ *)hrgn; /* force recalc of clipregion*/ cliphdc = NULL; MwPrepareDC(hdc); } if(hrgn) return ((MWRGNOBJ *)hrgn)->rgn->type; return NULLREGION; }
/*********************************************************************** * OffsetVisRgn (GDI.102) */ INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y ) { INT16 retval; HDC hdc = HDC_32( hdc16 ); DC * dc = DC_GetDCUpdate( hdc ); if (!dc) return ERROR; TRACE("%p %d,%d\n", hdc, x, y ); retval = OffsetRgn( dc->hVisRgn, x, y ); CLIPPING_UpdateGCRegion( dc ); GDI_ReleaseObj( hdc ); return retval; }
void COFSNcDlg2::OnSize(UINT nType, int cx, int cy) { OFS_NCDLG2_PARENT::OnSize(nType, cx, cy); // if(m_bRound) { RECT rw, r; GetWindowRect(&rw); OffsetRect(&rw, -rw.left, -rw.top); HRGN WinRgn; WinRgn = CreateRectRgn(0, 0, rw.right, rw.bottom); if(m_rgnTL != NULL) CombineRgn(WinRgn, WinRgn, m_rgnTL, RGN_DIFF); if(m_rgnTR != NULL) { GetRgnBox(m_rgnTR, &r); OffsetRgn(m_rgnTR, rw.right - r.right, 0); CombineRgn(WinRgn, WinRgn, m_rgnTR, RGN_DIFF); OffsetRgn(m_rgnTR, -(rw.right - r.right), 0); } if(m_rgnBL != NULL) { GetRgnBox(m_rgnBL, &r); OffsetRgn(m_rgnBL, 0, rw.bottom - r.bottom); CombineRgn(WinRgn, WinRgn, m_rgnBL, RGN_DIFF); OffsetRgn(m_rgnBL, 0, -(rw.bottom - r.bottom)); } if(m_rgnBR != NULL) { GetRgnBox(m_rgnBR, &r); OffsetRgn(m_rgnBR, rw.right - r.right, rw.bottom - r.bottom); CombineRgn(WinRgn, WinRgn, m_rgnBR, RGN_DIFF); OffsetRgn(m_rgnBR, -(rw.right - r.right), -(rw.bottom - r.bottom)); } SetWindowRgn(WinRgn, TRUE); DeleteObject(WinRgn); } // Switch maximize and restore buttons if(nType == SIZE_MAXIMIZED) { if(m_pBtnMax) m_pBtnMax->ShowWindow(FALSE); if(m_pBtnRestore) m_pBtnRestore->ShowWindow(TRUE); } if(nType == SIZE_RESTORED) { if(m_pBtnMax) m_pBtnMax->ShowWindow(TRUE); if(m_pBtnRestore) m_pBtnRestore->ShowWindow(FALSE); } Invalidate(FALSE); UpdateWindow(); }
void Test_OffsetRgn() { HRGN hrgn1, hrgn2; HDC hdc; hrgn1 = CreateRectRgn(0, 0, 0, 0); ok(hrgn1 != NULL, "CreateRectRgn failed\n"); ok_int(OffsetRgn(hrgn1, INT_MIN + 10, 10), NULLREGION); ok_int(OffsetRgn(hrgn1, 0xF000000, 0xF000000), NULLREGION); DeleteObject(hrgn1); hrgn1 = CreateRectRgn(0, 0, 100, 100); ok(hrgn1 != NULL, "CreateRectRgn failed\n"); ok_int(OffsetRgn(hrgn1, 10, 10), SIMPLEREGION); ok_int(OffsetRgn(hrgn1, 0x8000000 - 110, 10), ERROR); ok_int(OffsetRgn(hrgn1, 0x8000000 - 111, 10), SIMPLEREGION); DeleteObject(hrgn1); hrgn1 = CreateRectRgn(0, 0, 100, 100); ok(hrgn1 != NULL, "CreateRectRgn failed\n"); ok_int(OffsetRgn(hrgn1, -10, 10), SIMPLEREGION); ok_int(OffsetRgn(hrgn1, -(0x8000000 - 9), 10), ERROR); ok_int(OffsetRgn(hrgn1, -(0x8000000 - 10), 10), SIMPLEREGION); DeleteObject(hrgn1); hrgn1 = CreateRectRgn(0, 0, 10, 10); hrgn2 = CreateRectRgn(1000, 20, 1010, 30); ok_int(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), COMPLEXREGION); ok_int(OffsetRgn(hrgn1, 0x8000000 - 100, 10), ERROR); ok_int(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), SIMPLEREGION); DeleteObject(hrgn2); hrgn2 = CreateRectRgn(0, 0, 10, 10); ok_int(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), NULLREGION); hrgn1 = CreateRectRgn(0, 0, 0, 0); hdc = CreateCompatibleDC(NULL); ok_int(GetClipRgn(hdc, hrgn1), 0); ok_int(OffsetRgn(hrgn1, 10, 10), NULLREGION); }
/*Assumes that all regions are in the guest coordinates system*/ static void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window) { ContextInfo *c = renderspuGetWindowContext(window); RgnHandle rgn; GLboolean result = true; DEBUG_MSG_POETZSCH (("ApplyVisibleRegion %x\n", window)); if (!c || !c->context) return; rgn = NewRgn(); SetEmptyRgn(rgn); if (render_spu.hRootVisibleRegion) { /* The render_spu.hRootVisibleRegion has coordinates from the root * window. We intersect it with the rect of the OpenGL window we * currently process. */ SetRectRgn(rgn, window->x, window->y, window->x + window->BltInfo.width, window->y + window->BltInfo.height); SectRgn(render_spu.hRootVisibleRegion, rgn, rgn); /* Because the clipping is done in the coordinate space of the OpenGL * window we have to remove the x/y position from the newly created * region. */ OffsetRgn (rgn, -window->x, -window->y); } else { /* If there is not root clipping region is available, create a base * region with the size of the target window. This covers all * needed/possible space. */ SetRectRgn(rgn, 0, 0, window->BltInfo.width, window->BltInfo.height); } /* Now intersect the window clipping region with a additional region e.g. * for the seamless mode. */ if (window->hVisibleRegion) SectRgn(rgn, window->hVisibleRegion, rgn); if (rgn && !EmptyRgn(rgn)) { /* Set the clip region to the context */ result = render_spu.ws.aglSetInteger(c->context, AGL_CLIP_REGION, (const GLint*)rgn); CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): SetInteger Failed"); result = render_spu.ws.aglEnable(c->context, AGL_CLIP_REGION); CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): Enable Failed"); } /* Clear the region structure */ DisposeRgn (rgn); }
static void hugsprim_OffsetRgn_1(HugsStackPtr hugs_root) { HsPtr arg1; HsInt32 arg2; HsInt32 arg3; HsInt32 res1; arg1 = hugs->getPtr(); arg2 = hugs->getInt32(); arg3 = hugs->getInt32(); res1 = OffsetRgn(arg1, arg2, arg3); hugs->putInt32(res1); hugs->returnIO(hugs_root,1); }
// The structure region is set to the shape given to the SetShape method. static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn) { RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window); SetEmptyRgn(rgn); if (cachedRegion) { Rect windowRect; wxShapedMacWindowGetPos(window, &windowRect); //how big is the window CopyRgn(cachedRegion, rgn); //make a copy of our cached region OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size } }
/*********************************************************************** * OffsetVisRgn (GDI.102) */ INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y ) { INT16 retval; HDC hdc = HDC_32( hdc16 ); DC * dc = get_dc_ptr( hdc ); if (!dc) return ERROR; TRACE("%p %d,%d\n", hdc, x, y ); update_dc( dc ); retval = OffsetRgn( dc->hVisRgn, x, y ); CLIPPING_UpdateGCRegion( dc ); release_dc_ptr( dc ); return retval; }
LRESULT ControlMediaPlayer::Evento_Mouse_Movimiento(const int cX, const int cY, const UINT wParam) { UltimoMovimiento = GetTickCount(); if (EstaEnPantallaCompleta() == true) { DWL::SO::DWLMouse::Visible(TRUE); RECT Recta; POINT MousePos; DWL::SO::DWLMouse::ObtenerPosicion(&MousePos); HRGN RMP = CreateRectRgn(0, 0, 0, 0); GetWindowRgn(Sistema.App.ControlesMP.hWnd(), RMP); GetWindowRect(_hWnd, &Recta); int x; if (Recta.left > 0) x = ((Recta.right - Recta.left) - CONTROLESMP_ANCHO) / 2; else x = (((Recta.right + Recta.left) + CONTROLESMP_ANCHO) / 2) - CONTROLESMP_ANCHO; if (ControlesMP_Abajo == true) { int y = (Recta.bottom - Recta.top) - CONTROLESMP_ALTO; int r = OffsetRgn(RMP, x, y); if (PtInRegion(RMP, MousePos.x, MousePos.y) == TRUE) { Sistema.App.ControlesMP.Mostrar(_hWnd, ControlesMP_Abajo); } else { Sistema.App.ControlesMP.Ocultar(hWnd()); } } else { OffsetRgn(RMP, x, 0); if (PtInRegion(RMP, MousePos.x, MousePos.y) == TRUE) { Sistema.App.ControlesMP.Mostrar(_hWnd, ControlesMP_Abajo); } else { Sistema.App.ControlesMP.Ocultar(hWnd()); } } DeleteObject(RMP); } return 0; }
void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackground ) { GrafPtr formerPort ; GetPort( &formerPort ) ; SetPortWindowPort( (WindowRef)m_macWindow ) ; m_macNeedsErasing |= eraseBackground ; // if we already know that we will have to erase, there's no need to track the rest if ( !m_macNeedsErasing) { // we end only here if eraseBackground is false // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn // we will have to erase anyway RgnHandle updateRgn = NewRgn(); RgnHandle diffRgn = NewRgn() ; if ( updateRgn && diffRgn ) { GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn ); Point pt = {0,0} ; LocalToGlobal( &pt ) ; OffsetRgn( updateRgn , -pt.h , -pt.v ) ; DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ; if ( !EmptyRgn( diffRgn ) ) { m_macNeedsErasing = true ; } } if ( updateRgn ) DisposeRgn( updateRgn ); if ( diffRgn ) DisposeRgn( diffRgn ); if ( !m_macNeedsErasing ) { RgnHandle rectRgn = NewRgn() ; SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ; UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ; DisposeRgn( rectRgn ) ; } } InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ; // turn this on to debug the refreshing cycle #if wxMAC_DEBUG_REDRAW PaintRect( rect ) ; #endif SetPort( formerPort ) ; }
INT nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y ) { DC *dc = get_nulldrv_dc( dev ); INT ret = NULLREGION; if (dc->hClipRgn) { x = MulDiv( x, dc->vport_ext.cx, dc->wnd_ext.cx ); y = MulDiv( y, dc->vport_ext.cy, dc->wnd_ext.cy ); if (dc->layout & LAYOUT_RTL) x = -x; ret = OffsetRgn( dc->hClipRgn, x, y ); update_dc_clipping( dc ); } return ret; }
/*********************************************************************** * update_blit_data */ static void update_blit_data(struct macdrv_window_surface *surface) { HeapFree(GetProcessHeap(), 0, surface->blit_data); surface->blit_data = NULL; if (surface->drawn) { HRGN blit = CreateRectRgn(0, 0, 0, 0); if (CombineRgn(blit, surface->drawn, 0, RGN_COPY) > NULLREGION && (!surface->region || CombineRgn(blit, blit, surface->region, RGN_AND) > NULLREGION) && OffsetRgn(blit, surface->header.rect.left, surface->header.rect.top) > NULLREGION) surface->blit_data = get_region_data(blit, 0); DeleteObject(blit); } }
/*********************************************************************** * GetRandomRgn [GDI32.@] * * NOTES * This function is documented in MSDN online for the case of * iCode == SYSRGN (4). * * For iCode == 1 it should return the clip region * 2 " " " the meta region * 3 " " " the intersection of the clip with * the meta region (== 'Rao' region). * * See http://www.codeproject.com/gdi/cliprgnguide.asp */ INT WINAPI GetRandomRgn(HDC hDC, HRGN hRgn, INT iCode) { INT ret = 1; DC *dc = get_dc_ptr( hDC ); if (!dc) return -1; switch (iCode) { case 1: if (dc->hClipRgn) CombineRgn( hRgn, dc->hClipRgn, 0, RGN_COPY ); else ret = 0; break; case 2: if (dc->hMetaRgn) CombineRgn( hRgn, dc->hMetaRgn, 0, RGN_COPY ); else ret = 0; break; case 3: if (dc->hClipRgn && dc->hMetaRgn) CombineRgn( hRgn, dc->hClipRgn, dc->hMetaRgn, RGN_AND ); else if (dc->hClipRgn) CombineRgn( hRgn, dc->hClipRgn, 0, RGN_COPY ); else if (dc->hMetaRgn) CombineRgn( hRgn, dc->hMetaRgn, 0, RGN_COPY ); else ret = 0; break; case SYSRGN: /* == 4 */ update_dc( dc ); if (dc->hVisRgn) { CombineRgn( hRgn, dc->hVisRgn, 0, RGN_COPY ); /* On Windows NT/2000, the SYSRGN returned is in screen coordinates */ if (!(GetVersion() & 0x80000000)) OffsetRgn( hRgn, dc->vis_rect.left, dc->vis_rect.top ); } else if (!is_rect_empty( &dc->device_rect )) SetRectRgn( hRgn, dc->device_rect.left, dc->device_rect.top, dc->device_rect.right, dc->device_rect.bottom ); else ret = 0; break; default: WARN("Unknown code %d\n", iCode); ret = -1; break; } release_dc_ptr( dc ); return ret; }
wxWindowDC::wxWindowDC(wxWindow *window) { m_window = window ; wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; int x , y ; x = y = 0 ; window->MacWindowToRootWindow( &x , &y ) ; m_macLocalOrigin.x = x ; m_macLocalOrigin.y = y ; CopyRgn( (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; m_macPort = UMAGetWindowPort( windowref ) ; m_ok = TRUE ; SetBackground(window->MacGetBackgroundBrush()); }
static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect, RGNDATA *ClipList, DWORD *Size) { IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface; TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size); if (This->hWnd) { HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW); if (hDC) { HRGN hRgn = CreateRectRgn(0,0,0,0); if (GetRandomRgn(hDC, hRgn, SYSRGN)) { if (GetVersion() & 0x80000000) { /* map region to screen coordinates */ POINT org; GetDCOrgEx( hDC, &org ); OffsetRgn( hRgn, org.x, org.y ); } if (Rect) { HRGN hRgnClip = CreateRectRgn(Rect->left, Rect->top, Rect->right, Rect->bottom); CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND); DeleteObject(hRgnClip); } *Size = GetRegionData(hRgn, *Size, ClipList); } DeleteObject(hRgn); ReleaseDC(This->hWnd, hDC); } return WINED3D_OK; } else { static int warned = 0; if (warned++ < 10) FIXME("(%p,%p,%p,%p),stub!\n",This,Rect,ClipList,Size); if (Size) *Size=0; return WINEDDERR_NOCLIPLIST; } }
// Create a DC representing the whole screen wxScreenDC::wxScreenDC() { #if wxMAC_USE_CORE_GRAPHICS CGRect cgbounds ; cgbounds = CGDisplayBounds(CGMainDisplayID()); Rect bounds; bounds.top = (short)cgbounds.origin.y; bounds.left = (short)cgbounds.origin.x; bounds.bottom = bounds.top + (short)cgbounds.size.height; bounds.right = bounds.left + (short)cgbounds.size.width; WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow ); ShowWindow((WindowRef)m_overlayWindow); SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) ); m_width = (wxCoord)cgbounds.size.width; m_height = (wxCoord)cgbounds.size.height; #else m_macPort = CreateNewPort() ; GrafPtr port ; GetPort( &port ) ; SetPort( (GrafPtr) m_macPort ) ; Point pt = { 0,0 } ; LocalToGlobal( &pt ) ; SetPort( port ) ; m_macLocalOrigin.x = -pt.h ; m_macLocalOrigin.y = -pt.v ; BitMap screenBits; GetQDGlobalsScreenBits( &screenBits ); m_minX = screenBits.bounds.left ; SInt16 height ; GetThemeMenuBarHeight( &height ) ; m_minY = screenBits.bounds.top + height ; m_maxX = screenBits.bounds.right ; m_maxY = screenBits.bounds.bottom ; MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; #endif m_ok = true ; }
void TkMacSetUpClippingRgn( Drawable drawable) /* Drawable to update. */ { MacDrawable *macDraw = (MacDrawable *) drawable; if (macDraw->winPtr != NULL) { if (macDraw->flags & TK_CLIP_INVALID) { TkMacUpdateClipRgn(macDraw->winPtr); } /* * When a menu is up, the Mac does not expect drawing to occur and * does not clip out the menu. We have to do it ourselves. This * is pretty gross. */ if (macDraw->clipRgn != NULL) { if (tkUseMenuCascadeRgn == 1) { Point scratch = {0, 0}; GDHandle saveDevice; GWorldPtr saveWorld; GetGWorld(&saveWorld, &saveDevice); SetGWorld(TkMacGetDrawablePort(drawable), NULL); LocalToGlobal(&scratch); SetGWorld(saveWorld, saveDevice); if (tmpRgn == NULL) { tmpRgn = NewRgn(); } CopyRgn(tkMenuCascadeRgn, tmpRgn); OffsetRgn(tmpRgn, -scratch.h, -scratch.v); DiffRgn(macDraw->clipRgn, tmpRgn, tmpRgn); SetClip(tmpRgn); macDraw->toplevel->flags |= TK_DRAWN_UNDER_MENU; } else { SetClip(macDraw->clipRgn); } } } }
/*********************************************************************** * GetRandomRgn [GDI32.@] * * NOTES * This function is documented in MSDN online for the case of * iCode == SYSRGN (4). * * For iCode == 1 it should return the clip region * 2 " " " the meta region * 3 " " " the intersection of the clip with * the meta region (== 'Rao' region). * * See http://www.codeproject.com/gdi/cliprgnguide.asp */ INT WINAPI GetRandomRgn(HDC hDC, HRGN hRgn, INT iCode) { HRGN rgn; DC *dc = get_dc_ptr( hDC ); if (!dc) return -1; switch (iCode) { case 1: rgn = dc->hClipRgn; break; case 2: rgn = dc->hMetaRgn; break; case 3: rgn = dc->hMetaClipRgn; if(!rgn) rgn = dc->hClipRgn; if(!rgn) rgn = dc->hMetaRgn; break; case SYSRGN: /* == 4 */ update_dc( dc ); rgn = dc->hVisRgn; break; default: WARN("Unknown code %d\n", iCode); release_dc_ptr( dc ); return -1; } if (rgn) CombineRgn( hRgn, rgn, 0, RGN_COPY ); release_dc_ptr( dc ); /* On Windows NT/2000, the SYSRGN returned is in screen coordinates */ if (iCode == SYSRGN && !(GetVersion() & 0x80000000)) { POINT org; GetDCOrgEx( hDC, &org ); OffsetRgn( hRgn, org.x, org.y ); } return (rgn != 0); }
/*********************************************************************** * OffsetClipRgn (GDI32.@) */ INT WINAPI OffsetClipRgn( HDC hdc, INT x, INT y ) { INT ret = SIMPLEREGION; DC *dc = DC_GetDCUpdate( hdc ); if (!dc) return ERROR; TRACE("%p %d,%d\n", hdc, x, y ); if(dc->funcs->pOffsetClipRgn) { ret = dc->funcs->pOffsetClipRgn( dc->physDev, x, y ); /* FIXME: ret is just a success flag, we should return a proper value */ } else if (dc->hClipRgn) { ret = OffsetRgn( dc->hClipRgn, MulDiv( x, dc->vportExtX, dc->wndExtX ), MulDiv( y, dc->vportExtY, dc->wndExtY ) ); CLIPPING_UpdateGCRegion( dc ); } GDI_ReleaseObj( hdc ); return ret; }
/*********************************************************************** * __wine_set_visible_region (GDI32.@) */ void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect, const RECT *device_rect, struct window_surface *surface ) { DC * dc; if (!(dc = get_dc_ptr( hdc ))) return; TRACE( "%p %p %s %s %p\n", hdc, hrgn, wine_dbgstr_rect(vis_rect), wine_dbgstr_rect(device_rect), surface ); /* map region to DC coordinates */ OffsetRgn( hrgn, -vis_rect->left, -vis_rect->top ); if (dc->hVisRgn) DeleteObject( dc->hVisRgn ); dc->dirty = 0; dc->vis_rect = *vis_rect; dc->device_rect = *device_rect; dc->hVisRgn = hrgn; dibdrv_set_window_surface( dc, surface ); DC_UpdateXforms( dc ); update_dc_clipping( dc ); release_dc_ptr( dc ); }