/*================================ IsEmpty =================================*/ Boolean PTPaintSelection::IsEmpty() { #if PP_Target_Carbon if ( !mRegion || EmptyRgn(mRegion) ) #else if ( !mRegion || !*mRegion || EmptyRgn(mRegion) ) #endif return( true ); else return( false ); }
boolean shellupdatenow (WindowPtr wupdate) { /* can be called from within one of the callbacks to force an update to happen immediately, without waiting for the OS to generate an update event. dmb 8/14/90: can't we just call the normal update routine? this should be fine from the toolbox's point of view, but will not limit the update to contentrect. */ #ifdef MACVERSION hdlregion rgn; rgn = getupdateregion (wupdate); if (!EmptyRgn (rgn)) shellupdatewindow (wupdate); #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1 //Code change by Timothy Paustian Thursday, May 18, 2000 10:24:57 PM //Changed because calling getupdateregion returns a copy of the region //we have to dispose of it to prevent a memory leak DisposeRgn(rgn); #endif #endif #ifdef WIN95VERSION releasethreadglobals (); UpdateWindow ((HWND) wupdate); grabthreadglobals (); #endif return (true); } /*shellupdatenow*/
int TkRectInRegion( TkRegion region, int x, int y, unsigned int width, unsigned int height) { RgnHandle rgn = (RgnHandle) region; RgnHandle rectRgn, destRgn; int result; rectRgn = NewRgn(); destRgn = NewRgn(); SetRectRgn(rectRgn, x, y, x + width, y + height); SectRgn(rgn, rectRgn, destRgn); if (EmptyRgn(destRgn)) { result = RectangleOut; } else if (EqualRgn(rgn, destRgn)) { result = RectangleIn; } else { result = RectanglePart; } DisposeRgn(rectRgn); DisposeRgn(destRgn); return result; }
void wxTopLevelWindowMac::MacUpdate( long timestamp) { wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ; RgnHandle visRgn = NewRgn() ; GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), visRgn ); BeginUpdate( (WindowRef)m_macWindow ) ; RgnHandle updateRgn = NewRgn(); RgnHandle diffRgn = NewRgn() ; if ( updateRgn && diffRgn ) { #if 1 // macos internal control redraws clean up areas we'd like to redraw ourselves // therefore we pick the boundary rect and make sure we can redraw it // this has to be intersected by the visRgn in order to avoid drawing over its own // boundaries RgnHandle trueUpdateRgn = NewRgn() ; Rect trueUpdateRgnBoundary ; GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), trueUpdateRgn ); GetRegionBounds( trueUpdateRgn , &trueUpdateRgnBoundary ) ; RectRgn( updateRgn , &trueUpdateRgnBoundary ) ; SectRgn( updateRgn , visRgn , updateRgn ) ; if ( trueUpdateRgn ) DisposeRgn( trueUpdateRgn ) ; SetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ) ; #else GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ); #endif DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ; if ( !EmptyRgn( updateRgn ) ) { MacRedraw( updateRgn , timestamp , m_macNeedsErasing || !EmptyRgn( diffRgn ) ) ; } } if ( updateRgn ) DisposeRgn( updateRgn ); if ( diffRgn ) DisposeRgn( diffRgn ); if ( visRgn ) DisposeRgn( visRgn ) ; EndUpdate( (WindowRef)m_macWindow ) ; SetEmptyRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ; m_macNeedsErasing = false ; }
static int HandleMacEvents(void) { EventRecord theEvent; int eventFound = 0, needsUpdate = 0; Point currentMouse; WindowRef windowRef; Rect mouseRect; /* * Check for mouse moved events. These events aren't placed on the * system event queue unless we call WaitNextEvent. */ GetGlobalMouse(¤tMouse); if ((notifier.eventProcPtr != NULL) && !EqualPt(currentMouse, notifier.lastMousePosition)) { notifier.lastMousePosition = currentMouse; theEvent.what = nullEvent; if ((*notifier.eventProcPtr)(&theEvent) == true) { eventFound = 1; } } /* * Check for update events. Since update events aren't generated * until we call GetNextEvent, we may need to force a call to * GetNextEvent, even if the queue is empty. */ for (windowRef = FrontWindow(); windowRef != NULL; windowRef = GetNextWindow(windowRef)) { GetWindowUpdateRgn(windowRef, notifier.utilityRgn); if (!EmptyRgn(notifier.utilityRgn)) { needsUpdate = 1; break; } } /* * Process events from the OS event queue. */ while (needsUpdate || (GetEvQHdr()->qHead != NULL)) { GetGlobalMouse(¤tMouse); SetRect(&mouseRect, currentMouse.h, currentMouse.v, currentMouse.h + 1, currentMouse.v + 1); RectRgn(notifier.utilityRgn, &mouseRect); WaitNextEvent(everyEvent, &theEvent, 5, notifier.utilityRgn); needsUpdate = 0; if ((notifier.eventProcPtr != NULL) && ((*notifier.eventProcPtr)(&theEvent) == true)) { eventFound = 1; } } return eventFound; }
/*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); }
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 ) ; }
void TkMacInvalidateWindow( MacDrawable *macWin, /* Make window that's causing damage. */ int flag) /* Should be TK_WINDOW_ONLY or * TK_PARENT_WINDOW */ { if (flag == TK_WINDOW_ONLY) { InvalRgn(macWin->clipRgn); } else { if (!EmptyRgn(macWin->aboveClipRgn)) { InvalRgn(macWin->aboveClipRgn); } } }
void TkMacOSXInvalidateWindow( MacDrawable *macWin, /* Make window that's causing damage. */ int flag) /* Should be TK_WINDOW_ONLY or * TK_PARENT_WINDOW */ { WindowRef windowRef; CGrafPtr grafPtr; grafPtr=TkMacOSXGetDrawablePort((Drawable)macWin); windowRef=GetWindowFromPort(grafPtr); if (flag == TK_WINDOW_ONLY) { InvalWindowRgn(windowRef,macWin->clipRgn); } else { if (!EmptyRgn(macWin->aboveClipRgn)) { InvalWindowRgn(windowRef,macWin->aboveClipRgn); } } }
int TkScrollWindow( Tk_Window tkwin, /* The window to be scrolled. */ GC gc, /* GC for window to be scrolled. */ int x, /* Position rectangle to be scrolled. */ int y, int width, int height, int dx, /* Distance rectangle should be moved. */ int dy, TkRegion damageRgn) /* Region to accumulate damage in. */ { MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin); RgnHandle rgn = (RgnHandle) damageRgn; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; Rect srcRect, scrollRect; destPort = TkMacGetDrawablePort(Tk_WindowId(tkwin)); GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Due to the implementation below the behavior may be differnt * than X in certain cases that should never occur in Tk. The * scrollRect is the source rect extended by the offset (the union * of the source rect and the offset rect). Everything * in the extended scrollRect is scrolled. On X, it's possible * to "skip" over an area if the offset makes the source and * destination rects disjoint and non-aligned. */ SetRect(&srcRect, (short) (destDraw->xOff + x), (short) (destDraw->yOff + y), (short) (destDraw->xOff + x + width), (short) (destDraw->yOff + y + height)); scrollRect = srcRect; if (dx < 0) { scrollRect.left += dx; } else { scrollRect.right += dx; } if (dy < 0) { scrollRect.top += dy; } else { scrollRect.bottom += dy; } /* * Adjust clip region so that we don't copy any windows * that may overlap us. */ RectRgn(rgn, &srcRect); DiffRgn(rgn, destPort->visRgn, rgn); OffsetRgn(rgn, dx, dy); DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn); SetEmptyRgn(rgn); /* * 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 (tkUseMenuCascadeRgn == 1) { Point scratch = {0, 0}; MacDrawable *macDraw = (MacDrawable *) Tk_WindowId(tkwin); LocalToGlobal(&scratch); CopyRgn(tkMenuCascadeRgn, rgn); OffsetRgn(rgn, -scratch.h, -scratch.v); DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn); SetEmptyRgn(rgn); macDraw->toplevel->flags |= TK_DRAWN_UNDER_MENU; } ScrollRect(&scrollRect, dx, dy, rgn); SetGWorld(saveWorld, saveDevice); /* * Fortunantly, the region returned by ScrollRect is symanticlly * the same as what we need to return in this function. If the * region is empty we return zero to denote that no damage was * created. */ if (EmptyRgn(rgn)) { return 0; } else { return 1; } }
void shellupdatecontent (Rect contentrect) { /* update the portion of contectrect in shellwindow that needs updating, and validate the area updated 2/11/91 dmb: it turns out that we usually want to update the scroll bars at this time too, before redrawing contectrect 12/9/91 dmb: quick bail-out if update rgn is empty 9/22/92 dmb: don't draw scrollbars when update rgn is empty */ register hdlwindowinfo hw = shellwindowinfo; register hdlregion contentrgn, updatergn; hdlregion actualupdatergn; actualupdatergn = getupdateregion (shellwindow); if (EmptyRgn (actualupdatergn)) { #ifdef WIN95VERSION DeleteObject (actualupdatergn); #endif return; } shellupdatescrollbars (hw); updatergn = NewRgn (); CopyRgn (actualupdatergn, updatergn); /*window's update rgn is global*/ globaltolocalrgn (updatergn); #ifdef MACVERSION RectRgn (contentrgn = NewRgn (), &contentrect); #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1 //in carbon a copy of the update region is returned. DisposeRgn(actualupdatergn); actualupdatergn = nil; #endif #endif #ifdef WIN95VERSION DeleteObject (actualupdatergn); insetrect (&contentrect, -1, -1); contentrgn = CreateRectRgn (contentrect.left, contentrect.top, contentrect.right, contentrect.bottom); #endif SectRgn (contentrgn, updatergn, contentrgn); /*re-use contentrgn*/ #if defined(WIN95VERSION) && fldebug /****** DEBUG CODE *********/ if (false) { RECT rrr; GetClientRect (shellwindow, &rrr); DeleteObject(contentrgn); contentrgn = CreateRectRgn (rrr.left, rrr.top, rrr.right, rrr.bottom); FillRect (getport(), &rrr, GetStockObject (WHITE_BRUSH)); } #endif if (!EmptyRgn (contentrgn)) { (**hw).drawrgn = contentrgn; /*for display routines to refer to*/ //Code change by Timothy Paustian Monday, June 19, 2000 3:09:46 PM //Changed to Opaque call for Carbon #ifdef MACVERSION #if TARGET_API_MAC_CARBON == 1 ValidWindowRgn((WindowRef) hw, contentrgn); #else ValidRgn (contentrgn); /*no need to draw it again. do now to simulate beginupdate*/ #endif #endif #ifdef WIN95VERSION ValidateRgn (shellwindow, contentrgn); #endif pushcliprgn (contentrgn, false); (*shellglobals.updateroutine) (); popclip (); (**hw).drawrgn = nil; /*keep it neat, this guy is a temp*/ } DisposeRgn (updatergn); DisposeRgn (contentrgn); } /*shellupdatecontent*/
bool MCRegionIsEmpty(MCRegionRef self) { return EmptyRgn((RgnHandle)self); }
OSStatus HIRevolutionStackViewHandler(EventHandlerCallRef p_call_ref, EventRef p_event, void *p_data) { OSStatus t_status; t_status = eventNotHandledErr; UInt32 t_event_class; t_event_class = GetEventClass(p_event); UInt32 t_event_kind; t_event_kind = GetEventKind(p_event); HIRevolutionStackViewData *t_context; t_context = (HIRevolutionStackViewData *)p_data; switch(t_event_class) { case 'revo': switch(t_event_kind) { case 'rlnk': GetEventParameter(p_event, 'Stak', typeVoidPtr, NULL, sizeof(void *), NULL, &t_context -> stack); break; } break; case kEventClassHIObject: switch(t_event_kind) { case kEventHIObjectConstruct: { HIRevolutionStackViewData *t_data; t_data = new HIRevolutionStackViewData; t_data -> stack = NULL; GetEventParameter(p_event, kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(HIObjectRef), NULL, (HIObjectRef *)&t_data -> view); SetEventParameter(p_event, kEventParamHIObjectInstance, typeVoidPtr, sizeof(HIRevolutionStackViewData *), &t_data); t_status = noErr; } break; case kEventHIObjectInitialize: { GetEventParameter(p_event, 'Stak', typeVoidPtr, NULL, sizeof(void *), NULL, &t_context -> stack); Rect t_bounds; t_bounds . left = 0; // MW-2011-09-12: [[ MacScroll ]] Make sure the top of the HIView takes into // account the scroll. t_bounds . top = -t_context -> stack -> getscroll(); t_bounds . right = t_context -> stack -> getrect() . width; t_bounds . bottom = t_context -> stack -> getrect() . height; SetControlBounds((ControlRef)t_context -> view, &t_bounds); t_status = noErr; } break; case kEventHIObjectDestruct: { delete t_context; t_status = noErr; } break; } break; case kEventClassControl: switch(t_event_kind) { case kEventControlInitialize: { t_status = noErr; } break; case kEventControlDraw: { CGContextRef t_graphics; GetEventParameter(p_event, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(CGContextRef), NULL, &t_graphics); RgnHandle t_dirty_rgn; GetEventParameter(p_event, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof(RgnHandle), NULL, &t_dirty_rgn); if (t_context -> stack != NULL) { // Compute the clip region for players. RgnHandle t_clip_rgn, t_rect_rgn; t_clip_rgn = NULL; t_rect_rgn = NULL; for(MCPlayer *t_player = MCplayers; t_player != NULL; t_player = t_player -> getnextplayer()) if (t_player -> isvisible() && t_player -> getcard() == t_context -> stack -> getcurcard() && !t_player -> isbuffering()) { MCRectangle t_rect; Rect t_mac_rect; t_rect = t_player -> getactiverect(); if (t_clip_rgn == NULL) { t_clip_rgn = NewRgn(); CopyRgn((RgnHandle)t_dirty_rgn, t_clip_rgn); t_rect_rgn = NewRgn(); } SetRect(&t_mac_rect, t_rect . x, t_rect . y, t_rect . x + t_rect . width, t_rect . y + t_rect . height); RectRgn(t_rect_rgn, &t_mac_rect); DiffRgn(t_clip_rgn, t_rect_rgn, t_clip_rgn); } // We don't need the rect rgn anymore. if (t_rect_rgn != NULL) DisposeRgn(t_rect_rgn); // If the clip region is non-nil, then apply it. if (t_clip_rgn != NULL) { // As we can't clip to empty path, if the region is empty, we set the context // to nil. if (!EmptyRgn(t_clip_rgn)) { HIShapeRef t_shape; t_shape = HIShapeCreateWithQDRgn(t_clip_rgn); HIShapeReplacePathInCGContext(t_shape, t_graphics); CGContextClip(t_graphics); CFRelease(t_shape); } else t_graphics = nil; DisposeRgn(t_clip_rgn); } // If the graphics context is non-nil (i.e. we aren't completely occluded) then // draw something. if (t_graphics != nil) { // HIView gives us a context in top-left origin mode which isn't so good // for our CG rendering so, revert back to bottom-left. CGContextScaleCTM(t_graphics, 1.0, -1.0); CGContextTranslateCTM(t_graphics, 0.0, -t_context -> stack -> getcurcard() -> getrect() . height); // Save the context state CGContextSaveGState(t_graphics); // If we don't have an update pixmap, then use redrawwindow. if (s_update_pixmap == nil) { MCMacStackSurface t_surface(t_context -> stack, (MCRegionRef)t_dirty_rgn, t_graphics); t_context -> stack -> redrawwindow(&t_surface, (MCRegionRef)t_dirty_rgn); } else { int32_t t_height; t_height = t_context -> stack -> getcurcard() -> getrect() . height; MCRectangle t_rect; t_rect = MCRegionGetBoundingBox((MCRegionRef)t_dirty_rgn); CGRect t_area; t_area = CGRectMake(t_rect . x, t_height - (t_rect . y + t_rect . height), t_rect . width, t_rect . height); CGContextClearRect(t_graphics, t_area); void *t_bits; uint32_t t_stride; MCscreen -> lockpixmap(s_update_pixmap, t_bits, t_stride); MCMacRenderBitsToCG(t_graphics, t_area, t_bits, t_stride, t_context -> stack -> getwindowshape() != nil ? true : false); MCscreen -> unlockpixmap(s_update_pixmap, t_bits, t_stride); } // Restore the context state CGContextRestoreGState(t_graphics); } // MW-2011-11-23: [[ Bug ]] Force a redraw of the players on the stack // after we've drawn the rest of the content. This ensures players // which are just appearing don't disappear behind said content. for(MCPlayer *t_player = MCplayers; t_player != NULL; t_player = t_player -> getnextplayer()) if (t_player -> isvisible() && t_player -> getcard() == t_context -> stack -> getcurcard() && !t_player -> isbuffering()) MCDoAction((MovieController)t_player -> getMovieController(), mcActionDraw, t_context -> stack -> getqtwindow()); } t_status = noErr; } break; case kEventControlHitTest: break; case kEventControlGetPartRegion: { ControlPartCode t_part; GetEventParameter(p_event, kEventParamControlPart, typeControlPartCode, NULL, sizeof(ControlPartCode), NULL, &t_part); RgnHandle t_region; GetEventParameter(p_event, kEventParamControlRegion, typeQDRgnHandle, NULL, sizeof(RgnHandle), NULL, &t_region); } break; case kEventControlHiliteChanged: break; case kEventControlActivate: break; case kEventControlDeactivate: break; } break; } return t_status; }