void MCStack::onpaint(void) { HRGN t_update_region; t_update_region = CreateRectRgn(0, 0, 0, 0); GetUpdateRgn((HWND)window -> handle . window, t_update_region, FALSE); PAINTSTRUCT t_paint; BeginPaint((HWND)window -> handle . window, &t_paint); MCGRaster t_mask; MCGRaster *t_mask_ptr; if (MCWin32GetWindowShapeAlphaMask(getwindowshape(), t_mask)) t_mask_ptr = &t_mask; else t_mask_ptr = nil; MCWindowsStackSurface t_surface(t_mask_ptr, t_update_region, t_paint . hdc); if (t_surface.Lock()) { if (s_update_callback == nil) device_redrawwindow(&t_surface, (MCRegionRef)t_update_region); else s_update_callback(&t_surface, (MCRegionRef)t_update_region, s_update_context); t_surface.Unlock(); } EndPaint((HWND)window -> handle . window, &t_paint); DeleteObject(t_update_region); }
void MCStack::updatewindow(MCRegionRef p_region) { if (m_window_shape == nil || m_window_shape -> is_sharp) { InvalidateRgn((HWND)window -> handle . window, (HRGN)p_region, FALSE); UpdateWindow((HWND)window -> handle . window); } else { if (m_window_shape -> handle == nil) m_window_shape -> handle = MCscreen -> createpixmap(m_window_shape -> width, m_window_shape -> height, 0, False); Pixmap t_pixmap; t_pixmap = (Pixmap)m_window_shape -> handle; if (t_pixmap == nil) return; if (s_update_pixmap == nil) { MCWindowsLayeredStackSurface t_surface(t_pixmap, m_window_shape); redrawwindow(&t_surface, (MCRegionRef)p_region); } else MCscreen -> copyarea(s_update_pixmap, t_pixmap, 32, 0, 0, s_update_rect . width, s_update_rect . height, s_update_rect . x, s_update_rect . y, GXcopy); composite(); } }
void MCStack::onpaint(void) { if (s_update_pixmap == nil) { HRGN t_update_region; t_update_region = CreateRectRgn(0, 0, 0, 0); GetUpdateRgn((HWND)window -> handle . window, t_update_region, FALSE); PAINTSTRUCT t_paint; BeginPaint((HWND)window -> handle . window, &t_paint); MCWindowsStackSurface t_surface(this, t_update_region, t_paint . hdc); redrawwindow(&t_surface, (MCRegionRef)t_update_region); EndPaint((HWND)window -> handle . window, &t_paint); DeleteObject(t_update_region); } else { PAINTSTRUCT t_paint; BeginPaint((HWND)window -> handle . window, &t_paint); HDC t_src_dc = ((MCScreenDC *)MCscreen) -> getsrchdc(); HGDIOBJ t_old_object; t_old_object = SelectObject(t_src_dc, s_update_pixmap -> handle . pixmap); BitBlt(t_paint . hdc, s_update_rect . x, s_update_rect . y, s_update_rect . width, s_update_rect . height, t_src_dc, 0, 0, SRCCOPY); SelectObject(t_src_dc, t_old_object); EndPaint((HWND)window -> handle . window, &t_paint); } }
void MCStack::device_updatewindow(MCRegionRef p_region) { if (m_window_shape == nil || m_window_shape -> is_sharp) { InvalidateRgn((HWND)window -> handle . window, (HRGN)p_region, FALSE); UpdateWindow((HWND)window -> handle . window); } else { MCRectangle t_device_rect; t_device_rect = MCGRectangleGetIntegerBounds(MCResUserToDeviceRect(MCRectangleMake(0, 0, m_window_shape->width, m_window_shape->height))); HBITMAP t_bitmap = nil; void *t_bits = nil; if (m_window_shape -> handle == nil) { if (!create_temporary_dib(((MCScreenDC*)MCscreen)->getdsthdc(), t_device_rect.width, t_device_rect.height, t_bitmap, t_bits)) return; m_window_shape -> handle = t_bitmap; } else { t_bitmap = (HBITMAP)m_window_shape -> handle; BITMAP t_bitmap_struct; GetObjectA(t_bitmap, sizeof(BITMAP), &t_bitmap_struct); t_bits = t_bitmap_struct.bmBits; } MCGRaster t_raster; t_raster.width = t_device_rect.width; t_raster.height = t_device_rect.height; t_raster.pixels = t_bits; t_raster.stride = t_raster.width * sizeof(uint32_t); t_raster.format = kMCGRasterFormat_ARGB; MCGRaster t_mask; /* UNCHECKED */ MCWin32GetWindowShapeAlphaMask(m_window_shape, t_mask); MCWindowsLayeredStackSurface t_surface(t_raster, &t_mask); if (t_surface.Lock()) { if (s_update_callback == nil) device_redrawwindow(&t_surface, (MCRegionRef)p_region); else s_update_callback(&t_surface, (MCRegionRef)p_region, s_update_context); t_surface.Unlock(); composite(); } } }
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; }